summaryrefslogtreecommitdiff
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-10-03 18:07:13 +0200
committerGitHub <noreply@github.com>2018-10-03 18:07:13 +0200
commitf7cb23f9e3d3952869f3d3424854786b600b9c68 (patch)
tree1743a163ede5bf9b6a290ef35839c49b98571f1a /scene/main/node.cpp
parent874e3b4a37f68d12341d172fe7c6076cce4de517 (diff)
parentcb9559350f491b45ad0f2158fd38c87b35e41c4a (diff)
Merge pull request #22675 from DualMatrix/duplicate_err
Fixed error when duplicating node with signal from editor.
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index d3282c6ada..47ffbe2ff3 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2182,13 +2182,15 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
continue;
}
NodePath ptarget = p_original->get_path_to(target);
- Node *copytarget = p_copy->get_node(ptarget);
- // Cannot find a path to the duplicate target, so it seems it's not part
- // of the duplicated and not yet parented hierarchy, so at least try to connect
+ Node *copytarget = target;
+
+ // Atempt to find a path to the duplicate target, if it seems it's not part
+ // of the duplicated and not yet parented hierarchy then at least try to connect
// to the same target as the original
- if (!copytarget)
- copytarget = target;
+
+ if (p_copy->has_node(ptarget))
+ copytarget = p_copy->get_node(ptarget);
if (copy && copytarget) {
copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, E->get().flags);