Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CONNECT_DISCARD_EXTRA connection flag #38289

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,25 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
argc = bind_mem.size();
}

if (c.flags & CONNECT_DISCARD_EXTRA) {
List<MethodInfo> object_methods;
c.callable.get_object()->get_method_list(&object_methods);
int method_arg_count = -1;
for (List<MethodInfo>::Element *E = object_methods.front(); E; E = E->next()) {
if (E->get().name == c.callable.get_method()) {
method_arg_count = E->get().arguments.size();
break;
}
}

if (method_arg_count > -1) {
if (argc > method_arg_count) {
bind_mem.resize(method_arg_count);
argc = method_arg_count;
}
}
}

if (c.flags & CONNECT_DEFERRED) {
MessageQueue::get_singleton()->push_callable(c.callable, args, argc, true);
} else {
Expand Down Expand Up @@ -1762,6 +1781,7 @@ void Object::_bind_methods() {
BIND_ENUM_CONSTANT(CONNECT_PERSIST);
BIND_ENUM_CONSTANT(CONNECT_ONESHOT);
BIND_ENUM_CONSTANT(CONNECT_REFERENCE_COUNTED);
BIND_ENUM_CONSTANT(CONNECT_DISCARD_EXTRA);
}

void Object::call_deferred(const StringName &p_method, VARIANT_ARG_DECLARE) {
Expand Down
1 change: 1 addition & 0 deletions core/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ class Object {
CONNECT_PERSIST = 2, // hint for scene to save this connection
CONNECT_ONESHOT = 4,
CONNECT_REFERENCE_COUNTED = 8,
CONNECT_DISCARD_EXTRA = 16,
};

struct Connection {
Expand Down