Skip to content

Commit

Permalink
Merge pull request #56519 from RandomShaper/fix_scene_cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jan 5, 2022
2 parents 75c0628 + 2db9397 commit bb4157a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,32 @@ void Node::_propagate_enter_tree() {
}

void Node::_propagate_after_exit_tree() {
// Clear owner if it was not part of the pruned branch
if (data.owner) {
data.owner->data.owned.erase(data.OW);
data.owner = nullptr;
bool found = false;
Node *parent = data.parent;

while (parent) {
if (parent == data.owner) {
found = true;
break;
}

parent = parent->data.parent;
}

if (!found) {
data.owner->data.owned.erase(data.OW);
data.owner = nullptr;
}
}

data.blocked++;
for (int i = data.children.size() - 1; i >= 0; i--) {
data.children[i]->_propagate_after_exit_tree();
}
data.blocked--;

emit_signal(SceneStringNames::get_singleton()->tree_exited);
}

Expand Down

0 comments on commit bb4157a

Please sign in to comment.