diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-09-07 15:31:19 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-09-07 15:31:53 -0300 |
commit | 4b6846a59d785af3bef6a29958387ed0ee0f6575 (patch) | |
tree | 54e04d97444e034b3e8fb89deeef5fdcaa5948f3 | |
parent | fc50728d451e438db245d92698115cfc9c3720cf (diff) |
Ensure that tree_exited signal really happens after tree exited, fixes #19641
-rw-r--r-- | scene/main/node.cpp | 16 | ||||
-rw-r--r-- | scene/main/node.h | 1 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index e30f58e012..3d1614199a 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -238,6 +238,16 @@ void Node::_propagate_enter_tree() { // enter groups } +void Node::_propagate_after_exit_tree() { + + data.blocked++; + for (int i = 0; i < data.children.size(); i++) { + data.children[i]->_propagate_after_exit_tree(); + } + data.blocked--; + emit_signal(SceneStringNames::get_singleton()->tree_exited); +} + void Node::_propagate_exit_tree() { //block while removing children @@ -299,8 +309,6 @@ void Node::_propagate_exit_tree() { data.ready_notified = false; data.tree = NULL; data.depth = -1; - - emit_signal(SceneStringNames::get_singleton()->tree_exited); } void Node::move_child(Node *p_child, int p_pos) { @@ -1207,6 +1215,10 @@ void Node::remove_child(Node *p_child) { // validate owner p_child->_propagate_validate_owner(); + + if (data.inside_tree) { + p_child->_propagate_after_exit_tree(); + } } int Node::get_child_count() const { diff --git a/scene/main/node.h b/scene/main/node.h index f3422618ce..fb84981feb 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -166,6 +166,7 @@ private: void _propagate_enter_tree(); void _propagate_ready(); void _propagate_exit_tree(); + void _propagate_after_exit_tree(); void _propagate_validate_owner(); void _print_stray_nodes(); void _propagate_pause_owner(Node *p_owner); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 11268cc5c6..0b763d2433 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -598,6 +598,7 @@ void SceneTree::finish() { if (root) { root->_set_tree(NULL); + root->_propagate_after_exit_tree(); memdelete(root); //delete root } } |