Clear owners when pruning even out of the tree
This commit is contained in:
parent
eb36566c34
commit
0b650b3e41
@ -252,7 +252,7 @@ void Node::_propagate_enter_tree() {
|
|||||||
// enter groups
|
// enter groups
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::_propagate_after_exit_tree() {
|
void Node::_propagate_after_exit_branch(bool p_exiting_tree) {
|
||||||
// Clear owner if it was not part of the pruned branch
|
// Clear owner if it was not part of the pruned branch
|
||||||
if (data.owner) {
|
if (data.owner) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -275,12 +275,14 @@ void Node::_propagate_after_exit_tree() {
|
|||||||
|
|
||||||
data.blocked++;
|
data.blocked++;
|
||||||
for (int i = 0; i < data.children.size(); i++) {
|
for (int i = 0; i < data.children.size(); i++) {
|
||||||
data.children[i]->_propagate_after_exit_tree();
|
data.children[i]->_propagate_after_exit_branch(p_exiting_tree);
|
||||||
}
|
}
|
||||||
data.blocked--;
|
data.blocked--;
|
||||||
|
|
||||||
|
if (p_exiting_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->tree_exited);
|
emit_signal(SceneStringNames::get_singleton()->tree_exited);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Node::_propagate_exit_tree() {
|
void Node::_propagate_exit_tree() {
|
||||||
//block while removing children
|
//block while removing children
|
||||||
@ -1265,9 +1267,7 @@ void Node::remove_child(Node *p_child) {
|
|||||||
p_child->data.parent = nullptr;
|
p_child->data.parent = nullptr;
|
||||||
p_child->data.pos = -1;
|
p_child->data.pos = -1;
|
||||||
|
|
||||||
if (data.inside_tree) {
|
p_child->_propagate_after_exit_branch(data.inside_tree);
|
||||||
p_child->_propagate_after_exit_tree();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Node::get_child_count() const {
|
int Node::get_child_count() const {
|
||||||
|
@ -180,7 +180,7 @@ private:
|
|||||||
void _propagate_enter_tree();
|
void _propagate_enter_tree();
|
||||||
void _propagate_ready();
|
void _propagate_ready();
|
||||||
void _propagate_exit_tree();
|
void _propagate_exit_tree();
|
||||||
void _propagate_after_exit_tree();
|
void _propagate_after_exit_branch(bool p_exiting_tree);
|
||||||
void _propagate_physics_interpolated(bool p_interpolated);
|
void _propagate_physics_interpolated(bool p_interpolated);
|
||||||
void _print_stray_nodes();
|
void _print_stray_nodes();
|
||||||
void _propagate_pause_owner(Node *p_owner);
|
void _propagate_pause_owner(Node *p_owner);
|
||||||
|
@ -707,7 +707,7 @@ void SceneTree::finish() {
|
|||||||
|
|
||||||
if (root) {
|
if (root) {
|
||||||
root->_set_tree(nullptr);
|
root->_set_tree(nullptr);
|
||||||
root->_propagate_after_exit_tree();
|
root->_propagate_after_exit_branch(true);
|
||||||
memdelete(root); //delete root
|
memdelete(root); //delete root
|
||||||
root = nullptr;
|
root = nullptr;
|
||||||
}
|
}
|
||||||
@ -2246,7 +2246,7 @@ SceneTree::SceneTree() {
|
|||||||
SceneTree::~SceneTree() {
|
SceneTree::~SceneTree() {
|
||||||
if (root) {
|
if (root) {
|
||||||
root->_set_tree(nullptr);
|
root->_set_tree(nullptr);
|
||||||
root->_propagate_after_exit_tree();
|
root->_propagate_after_exit_branch(true);
|
||||||
memdelete(root);
|
memdelete(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user