Signals: Manually port most of remaining connect_compat uses
It's tedious work... Some can't be ported as they depend on private or protected methods of different classes, which is not supported by callable_mp (even if it's a class inherited by the current one).
This commit is contained in:
parent
01afc442c7
commit
f742dabafe
50 changed files with 187 additions and 244 deletions
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "node.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "core/core_string_names.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/message_queue.h"
|
||||
|
|
@ -46,6 +44,8 @@
|
|||
#include "editor/editor_settings.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
VARIANT_ENUM_CAST(Node::PauseMode);
|
||||
|
||||
int Node::orphan_node_count = 0;
|
||||
|
|
@ -2346,15 +2346,18 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
|
|||
|
||||
Node *copytarget = target;
|
||||
|
||||
// Atempt to find a path to the duplicate target, if it seems it's not part
|
||||
// Attempt 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 (p_copy->has_node(ptarget))
|
||||
copytarget = p_copy->get_node(ptarget);
|
||||
|
||||
if (copy && copytarget && !copy->is_connected_compat(E->get().signal.get_name(), copytarget, E->get().callable.get_method())) {
|
||||
copy->connect_compat(E->get().signal.get_name(), copytarget, E->get().callable.get_method(), E->get().binds, E->get().flags);
|
||||
if (copy && copytarget) {
|
||||
const Callable copy_callable = Callable(copytarget, E->get().callable.get_method());
|
||||
if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) {
|
||||
copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2509,10 +2512,10 @@ void Node::_replace_connections_target(Node *p_new_target) {
|
|||
Connection &c = E->get();
|
||||
|
||||
if (c.flags & CONNECT_PERSIST) {
|
||||
c.signal.get_object()->disconnect_compat(c.signal.get_name(), this, c.callable.get_method());
|
||||
c.signal.get_object()->disconnect(c.signal.get_name(), Callable(this, c.callable.get_method()));
|
||||
bool valid = p_new_target->has_method(c.callable.get_method()) || Ref<Script>(p_new_target->get_script()).is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.callable.get_method());
|
||||
ERR_CONTINUE_MSG(!valid, "Attempt to connect signal '" + c.signal.get_object()->get_class() + "." + c.signal.get_name() + "' to nonexistent method '" + c.callable.get_object()->get_class() + "." + c.callable.get_method() + "'.");
|
||||
c.signal.get_object()->connect_compat(c.signal.get_name(), p_new_target, c.callable.get_method(), c.binds, c.flags);
|
||||
c.signal.get_object()->connect(c.signal.get_name(), Callable(p_new_target, c.callable.get_method()), c.binds, c.flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue