Skip to content

Commit

Permalink
Merge pull request #78847 from Sauermann/fix-sibling-fail
Browse files Browse the repository at this point in the history
Fix `Node::add_sibling` parent check
  • Loading branch information
akien-mga committed Jul 8, 2023
2 parents 46cd84b + b02dff6 commit 0df4237
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,9 +1403,9 @@ void Node::add_child(Node *p_child, bool p_force_readable_name, InternalMode p_i
void Node::add_sibling(Node *p_sibling, bool p_force_readable_name) {
ERR_FAIL_COND_MSG(data.inside_tree && !Thread::is_main_thread(), "Adding a sibling to a node inside the SceneTree is only allowed from the main thread. Use call_deferred(\"add_sibling\",node).");
ERR_FAIL_NULL(p_sibling);
ERR_FAIL_NULL(data.parent);
ERR_FAIL_COND_MSG(p_sibling == this, vformat("Can't add sibling '%s' to itself.", p_sibling->get_name())); // adding to itself!
ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, `add_sibling()` failed. Consider using `add_sibling.call_deferred(sibling)` instead.");
ERR_FAIL_NULL(data.parent);
ERR_FAIL_COND_MSG(data.parent->data.blocked > 0, "Parent node is busy setting up children, `add_sibling()` failed. Consider using `add_sibling.call_deferred(sibling)` instead.");

data.parent->add_child(p_sibling, p_force_readable_name, data.internal_mode);
data.parent->_update_children_cache();
Expand Down

0 comments on commit 0df4237

Please sign in to comment.