diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-13 15:50:31 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-13 15:50:31 -0300 |
commit | d03f1131d75204fc0eb2d30896d4aff132c790aa (patch) | |
tree | 9bec2071a9b75e6a407d9f416190708dc7c7f4c1 /scene/main/node.cpp | |
parent | fc54830f1aa84534233c2a599e0121eba4255a07 (diff) | |
parent | dc2ea39f242979f69be3469bea8ef2467ab98b34 (diff) |
Merge pull request #5058 from neikeq/pr-issue-1461
Preserve signal connections when replacing target node
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r-- | scene/main/node.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index f8af83e23b..cfc7116d19 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1770,6 +1770,8 @@ void Node::replace_by(Node* p_node,bool p_keep_data) { } } + _replace_connections_target(p_node); + if (data.owner) { for(int i=0;i<get_child_count();i++) find_owned_by(data.owner,get_child(i),&owned_by_owner); @@ -1808,6 +1810,20 @@ void Node::replace_by(Node* p_node,bool p_keep_data) { } +void Node::_replace_connections_target(Node* p_new_target) { + + List<Connection> cl; + get_signals_connected_to_this(&cl); + + for(List<Connection>::Element *E=cl.front();E;E=E->next()) { + + Connection &c=E->get(); + + c.source->disconnect(c.signal,this,c.method); + c.source->connect(c.signal,p_new_target,c.method,c.binds,c.flags); + } +} + Vector<Variant> Node::make_binds(VARIANT_ARG_DECLARE) { |