From 9cf13cedfd28344756cfb4267edf33b3f5e27235 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:02:43 +0200 Subject: [PATCH] Ensure binds are duplicated with `Node` signals --- scene/main/node.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 3500b2201af..d8f38c91489 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2722,9 +2722,15 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { copytarget = p_copy->get_node(ptarget); } - if (copy && copytarget) { - const Callable copy_callable = Callable(copytarget, E.callable.get_method()); + if (copy && copytarget && E.callable.get_method() != StringName()) { + Callable copy_callable = Callable(copytarget, E.callable.get_method()); if (!copy->is_connected(E.signal.get_name(), copy_callable)) { + int arg_count = E.callable.get_bound_arguments_count(); + if (arg_count > 0) { + copy_callable = copy_callable.bindv(E.callable.get_bound_arguments()); + } else if (arg_count < 0) { + copy_callable = copy_callable.unbind(-arg_count); + } copy->connect(E.signal.get_name(), copy_callable, E.flags); } }