Merge pull request #75382 from AThousandShips/duplicate_bind

Ensure binds are duplicated with `Node` signals
This commit is contained in:
Rémi Verschelde 2023-09-01 16:00:05 +02:00
commit 39b1d860c3
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -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);
}
}