Browse Source

Merge pull request #12830 from ianb96/node_replace_signal

Fix signals disconnecting on changing target node type
Rémi Verschelde 7 năm trước cách đây
mục cha
commit
66c1d9e48e
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      scene/main/node.cpp

+ 3 - 1
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);
 		}
 	}