summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-14 00:03:42 +0100
committerGitHub <noreply@github.com>2017-11-14 00:03:42 +0100
commit66c1d9e48ebd5402d44125cb1c47723b17d463e8 (patch)
tree6d0133079c9fcab56945f5cb84f85355cec0a076
parentaf6f096427c27303a8c791ea0737a34f879711ea (diff)
parent12b4e232b279161afbc6b0f6805f49f6f0d91074 (diff)
Merge pull request #12830 from ianb96/node_replace_signal
Fix signals disconnecting on changing target node type
-rwxr-xr-xscene/main/node.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 1889c09d9e..d38c688241 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2411,7 +2411,9 @@ void Node::_replace_connections_target(Node *p_new_target) {
if (c.flags & CONNECT_PERSIST) {
c.source->disconnect(c.signal, this, c.method);
- ERR_CONTINUE(!p_new_target->has_method(c.method));
+ bool valid = p_new_target->has_method(c.method) || p_new_target->get_script().is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.method);
+ ERR_EXPLAIN("Attempt to connect signal \'" + c.source->get_class() + "." + c.signal + "\' to nonexistent method \'" + c.target->get_class() + "." + c.method + "\'");
+ ERR_CONTINUE(!valid);
c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags);
}
}