summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2020-12-05 00:32:53 +0100
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2020-12-05 00:32:57 +0100
commite2f703782404db36ca2909e89e79dc2ba9634b95 (patch)
tree7cec24fc6ac86037ca892886dcd33e52164e3aa3
parent04bef80b42408f45d7838f9ef29f0e0553957475 (diff)
C#: Fix multiple awaits to same signal result in connect error
Multiple calls to the same `await ToSignal` were resulting in "signal already connected to slot" error because the custom callable comparer was wrong. Comparing only the signal awaiter handle is the correct way (it's unique for the target).
-rw-r--r--modules/mono/signal_awaiter_utils.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index bd67b03c8e..28777002f5 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -48,18 +48,10 @@ Error gd_mono_connect_signal_awaiter(Object *p_source, const StringName &p_signa
}
bool SignalAwaiterCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) {
+ // Only called if both instances are of type SignalAwaiterCallable. Static cast is safe.
const SignalAwaiterCallable *a = static_cast<const SignalAwaiterCallable *>(p_a);
const SignalAwaiterCallable *b = static_cast<const SignalAwaiterCallable *>(p_b);
-
- if (a->target_id != b->target_id) {
- return false;
- }
-
- if (a->signal != b->signal) {
- return false;
- }
-
- return true;
+ return a->awaiter_handle.handle == b->awaiter_handle.handle;
}
bool SignalAwaiterCallable::compare_less(const CallableCustom *p_a, const CallableCustom *p_b) {