From 628999772474984310a45ee55e224c38a58e237b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Wed, 15 Mar 2017 04:26:23 +0100 Subject: [PATCH 1/2] Fix ambiguity in StringName (null data vs. data with empty string) --- core/string_db.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/string_db.cpp b/core/string_db.cpp index 02e0b5b267..6cd9ee506f 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -288,6 +288,9 @@ StringName::StringName(const String& p_name) { ERR_FAIL_COND(!configured); + if (p_name.empty()) + return; + _global_lock(); uint32_t hash = p_name.hash(); From 148566b31b1b5876662982c18adff137f784533d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Wed, 15 Mar 2017 04:27:16 +0100 Subject: [PATCH 2/2] Fix redundant connections saved in sub-inheritance --- scene/resources/packed_scene.cpp | 53 ++++++++++++++++++-------------- scene/resources/packed_scene.h | 2 +- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index f320570c2c..3bbe5e13bb 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1548,34 +1548,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 ss=this; - NodePath np_from; + do { + for(int i=0;iconnections.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; + + 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); + } + + NodePath np_to; + + 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); + } + + 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; + } } - NodePath np_to; - - if (c.to&FLAG_ID_IS_PATH) { - np_to=node_paths[c.to&FLAG_MASK]; - } else { - np_to=get_node_path(c.to); - } - - StringName sn_signal=names[c.signal]; - StringName sn_method=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 aedc4d70d1..c7c30354e4 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -165,7 +165,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 get_editable_instances() const;