Browse Source

Merge pull request #78019 from Sauermann/fix-remove-child-inconsistency

Fix parent inconsistency in `Node::remove_child`
Rémi Verschelde 2 years ago
parent
commit
fd2f33942b
1 changed files with 3 additions and 3 deletions
  1. 3 3
      scene/main/node.cpp

+ 3 - 3
scene/main/node.cpp

@@ -1439,12 +1439,12 @@ void Node::remove_child(Node *p_child) {
 	bool success = data.children.erase(p_child->data.name);
 	bool success = data.children.erase(p_child->data.name);
 	ERR_FAIL_COND_MSG(!success, "Children name does not match parent name in hashtable, this is a bug.");
 	ERR_FAIL_COND_MSG(!success, "Children name does not match parent name in hashtable, this is a bug.");
 
 
-	notification(NOTIFICATION_CHILD_ORDER_CHANGED);
-	emit_signal(SNAME("child_order_changed"));
-
 	p_child->data.parent = nullptr;
 	p_child->data.parent = nullptr;
 	p_child->data.index = -1;
 	p_child->data.index = -1;
 
 
+	notification(NOTIFICATION_CHILD_ORDER_CHANGED);
+	emit_signal(SNAME("child_order_changed"));
+
 	if (data.inside_tree) {
 	if (data.inside_tree) {
 		p_child->_propagate_after_exit_tree();
 		p_child->_propagate_after_exit_tree();
 	}
 	}