diff options
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r-- | scene/main/node.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index e80de68e3b..5888760973 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -71,6 +71,8 @@ void Node::_notification(int p_notification) { } break; case NOTIFICATION_ENTER_TREE: { + ERR_FAIL_COND(!get_viewport()); + ERR_FAIL_COND(!get_tree()); if (data.pause_mode == PAUSE_MODE_INHERIT) { @@ -94,6 +96,8 @@ void Node::_notification(int p_notification) { } break; case NOTIFICATION_EXIT_TREE: { + ERR_FAIL_COND(!get_viewport()); + ERR_FAIL_COND(!get_tree()); get_tree()->node_count--; orphan_node_count++; @@ -840,6 +844,8 @@ bool Node::is_processing_internal() const { void Node::set_process_priority(int p_priority) { data.process_priority = p_priority; + ERR_FAIL_COND(!data.tree); + if (is_processing()) data.tree->make_group_changed("idle_process"); @@ -949,6 +955,7 @@ void Node::set_name(const String &p_name) { if (is_inside_tree()) { emit_signal("renamed"); + get_tree()->node_renamed(this); get_tree()->tree_changed(); } } @@ -1164,7 +1171,7 @@ void Node::add_child(Node *p_child, bool p_legible_unique_name) { ERR_FAIL_NULL(p_child); if (p_child == this) { - ERR_EXPLAIN("Can't add child '" + p_child->get_name() + "' to itself.") + ERR_EXPLAIN("Can't add child '" + p_child->get_name() + "' to itself."); ERR_FAIL_COND(p_child == this); // adding to itself! } @@ -1198,7 +1205,7 @@ void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_uniq if (is_a_parent_of(p_node)) { move_child(p_child, p_node->get_position_in_parent() + 1); } else { - WARN_PRINTS("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent.") + WARN_PRINTS("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent."); } } @@ -1392,7 +1399,7 @@ Node *Node::get_node(const NodePath &p_path) const { Node *node = get_node_or_null(p_path); if (!node) { ERR_EXPLAIN("Node not found: " + p_path); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_V(NULL); } return node; } @@ -2076,7 +2083,9 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const } } - node->set_name(get_name()); + if (get_name() != String()) { + node->set_name(get_name()); + } #ifdef TOOLS_ENABLED if ((p_flags & DUPLICATE_FROM_EDITOR) && r_duplimap) @@ -2474,21 +2483,18 @@ bool Node::has_node_and_resource(const NodePath &p_path) const { if (!has_node(p_path)) return false; - Node *node = get_node(p_path); - - bool result = false; - - node->get_indexed(p_path.get_subnames(), &result); + RES res; + Vector<StringName> leftover_path; + Node *node = get_node_and_resource(p_path, res, leftover_path, false); - return result; + return (node && res.is_valid()); } Array Node::_get_node_and_resource(const NodePath &p_path) { - Node *node; RES res; Vector<StringName> leftover_path; - node = get_node_and_resource(p_path, res, leftover_path); + Node *node = get_node_and_resource(p_path, res, leftover_path, false); Array result; if (node) @@ -2518,7 +2524,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str int j = 0; // If not p_last_is_property, we shouldn't consider the last one as part of the resource - for (; j < p_path.get_subname_count() - p_last_is_property; j++) { + for (; j < p_path.get_subname_count() - (int)p_last_is_property; j++) { RES new_res = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j)); if (new_res.is_null()) { |