diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 480feaf00a4e..dbf05d73aa30 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1421,8 +1421,12 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name, InternalM //recognize children created in this node constructor p_child->data.parent_owned = data.in_constructor; add_child_notify(p_child); - notification(NOTIFICATION_CHILD_ORDER_CHANGED); - emit_signal(SNAME("child_order_changed")); + if(!deferred_add_child) { + deferred_add_child = true; + call_deferred("notification", NOTIFICATION_CHILD_ORDER_CHANGED); + call_deferred("emit_signal", SNAME("child_order_changed")); + set_deferred("deferred_add_child", false); + } } void Node::add_child(Node *p_child, bool p_force_readable_name, InternalMode p_internal) { diff --git a/scene/main/node.h b/scene/main/node.h index 9700c9a8744b..9b17ea3b3708 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -392,6 +392,8 @@ class Node : public Object { InternalMode get_internal_mode() const; + bool deferred_add_child = false; + void add_child(Node *p_child, bool p_force_readable_name = false, InternalMode p_internal = INTERNAL_MODE_DISABLED); void add_sibling(Node *p_sibling, bool p_force_readable_name = false); void remove_child(Node *p_child);