Merge pull request #56519 from RandomShaper/fix_scene_cleared

This commit is contained in:
Rémi Verschelde 2022-01-05 15:32:06 +01:00 committed by GitHub
commit bb4157a9af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}