Node::add_child Check for cyclic dependency
Node Replace string addition with vformat()
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
(cherry picked from commit 81388db8a7
)
This commit is contained in:
parent
4941d2001c
commit
6d48b67f14
@ -313,7 +313,7 @@ void Node::_propagate_exit_tree() {
|
||||
|
||||
void Node::move_child(Node *p_child, int p_pos) {
|
||||
ERR_FAIL_NULL(p_child);
|
||||
ERR_FAIL_INDEX_MSG(p_pos, data.children.size() + 1, "Invalid new child position: " + itos(p_pos) + ".");
|
||||
ERR_FAIL_INDEX_MSG(p_pos, data.children.size() + 1, vformat("Invalid new child position: %d.", p_pos));
|
||||
ERR_FAIL_COND_MSG(p_child->data.parent != this, "Child is not a child of this node.");
|
||||
ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, move_child() failed. Consider using call_deferred(\"move_child\") instead (or \"popup\" if this is from a popup).");
|
||||
|
||||
@ -1127,8 +1127,11 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
|
||||
|
||||
void Node::add_child(Node *p_child, bool p_legible_unique_name) {
|
||||
ERR_FAIL_NULL(p_child);
|
||||
ERR_FAIL_COND_MSG(p_child == this, "Can't add child '" + p_child->get_name() + "' to itself."); // adding to itself!
|
||||
ERR_FAIL_COND_MSG(p_child->data.parent, "Can't add child '" + p_child->get_name() + "' to '" + get_name() + "', already has a parent '" + p_child->data.parent->get_name() + "'."); //Fail if node has a parent
|
||||
ERR_FAIL_COND_MSG(p_child == this, vformat("Can't add child '%s' to itself.", p_child->get_name())); // adding to itself!
|
||||
ERR_FAIL_COND_MSG(p_child->data.parent, vformat("Can't add child '%s' to '%s', already has a parent '%s'.", p_child->get_name(), get_name(), p_child->data.parent->get_name())); //Fail if node has a parent
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND_MSG(p_child->is_a_parent_of(this), vformat("Can't add child '%s' to '%s' as it would result in a cyclic dependency since '%s' is already a parent of '%s'.", p_child->get_name(), get_name(), p_child->get_name(), get_name()));
|
||||
#endif
|
||||
ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\", child) instead.");
|
||||
|
||||
/* Validate name */
|
||||
@ -1198,7 +1201,7 @@ void Node::remove_child(Node *p_child) {
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_MSG(idx == -1, "Cannot remove child node " + p_child->get_name() + " as it is not a child of this node.");
|
||||
ERR_FAIL_COND_MSG(idx == -1, vformat("Cannot remove child node '%s' as it is not a child of this node.", p_child->get_name()));
|
||||
//ERR_FAIL_COND( p_child->data.blocked > 0 );
|
||||
|
||||
//if (data.scene) { does not matter
|
||||
|
Loading…
Reference in New Issue
Block a user