diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/control.cpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | scene/main/node.cpp | 18 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 47 | ||||
-rw-r--r-- | scene/resources/packed_scene.h | 2 |
4 files changed, 41 insertions, 28 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2f40f0acec..a8e364a4cd 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2514,6 +2514,8 @@ void Control::_bind_methods() { ADD_SIGNAL(MethodInfo("size_flags_changed")); ADD_SIGNAL(MethodInfo("minimum_size_changed")); ADD_SIGNAL(MethodInfo("modal_closed")); + + BIND_VMETHOD(MethodInfo("has_point", PropertyInfo(Variant::VECTOR2, "point"))); } Control::Control() { diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 0245944154..c13ed232a7 100644..100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1719,6 +1719,9 @@ void Node::get_owned_by(Node *p_by, List<Node *> *p_owned) { void Node::_set_owner_nocheck(Node *p_owner) { + if (data.owner == p_owner) + return; + ERR_FAIL_COND(data.owner); data.owner = p_owner; data.owner->data.owned.push_back(this); @@ -2020,12 +2023,13 @@ void Node::remove_and_skip() { bool clear = true; for (int i = 0; i < data.children.size(); i++) { - if (!data.children[i]->get_owner()) + Node *c_node = data.children[i]; + if (!c_node->get_owner()) continue; - remove_child(data.children[i]); - data.children[i]->_propagate_replace_owner(this, NULL); - children.push_back(data.children[i]); + remove_child(c_node); + c_node->_propagate_replace_owner(this, NULL); + children.push_back(c_node); clear = false; break; } @@ -2036,9 +2040,9 @@ void Node::remove_and_skip() { while (!children.empty()) { - Node *c = children.front()->get(); - data.parent->add_child(c); - c->_propagate_replace_owner(NULL, new_owner); + Node *c_node = children.front()->get(); + data.parent->add_child(c_node); + c_node->_propagate_replace_owner(NULL, new_owner); children.pop_front(); } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index e46d9db7bc..76c6543a2f 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1516,34 +1516,41 @@ Array SceneState::get_connection_binds(int p_idx) const { return binds; } -bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) const { +bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) { - for (int i = 0; i < connections.size(); i++) { - const ConnectionData &c = connections[i]; + // this method cannot be const because of this + Ref<SceneState> ss = this; - NodePath np_from; + do { + for (int i = 0; i < ss->connections.size(); i++) { + const ConnectionData &c = ss->connections[i]; - if (c.from & FLAG_ID_IS_PATH) { - np_from = node_paths[c.from & FLAG_MASK]; - } else { - np_from = get_node_path(c.from); - } + NodePath np_from; - NodePath np_to; + if (c.from & FLAG_ID_IS_PATH) { + np_from = ss->node_paths[c.from & FLAG_MASK]; + } else { + np_from = ss->get_node_path(c.from); + } - if (c.to & FLAG_ID_IS_PATH) { - np_to = node_paths[c.to & FLAG_MASK]; - } else { - np_to = get_node_path(c.to); - } + NodePath np_to; - StringName sn_signal = names[c.signal]; - StringName sn_method = names[c.method]; + if (c.to & FLAG_ID_IS_PATH) { + np_to = ss->node_paths[c.to & FLAG_MASK]; + } else { + np_to = ss->get_node_path(c.to); + } - if (np_from == p_node_from && sn_signal == p_signal && np_to == p_node_to && sn_method == p_method) { - return true; + StringName sn_signal = ss->names[c.signal]; + StringName sn_method = ss->names[c.method]; + + if (np_from == p_node_from && sn_signal == p_signal && np_to == p_node_to && sn_method == p_method) { + return true; + } } - } + + ss = ss->_get_base_scene_state(); + } while (ss.is_valid()); return false; } diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index b0e89205cb..fe451884f5 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -163,7 +163,7 @@ public: int get_connection_flags(int p_idx) const; Array get_connection_binds(int p_idx) const; - bool has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) const; + bool has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method); Vector<NodePath> get_editable_instances() const; |