diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-01-18 17:20:56 +0100 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-09-20 16:39:09 +0200 |
commit | 203d3be200c9b607e5eaba82d9a267813a6700cd (patch) | |
tree | ced60a02eabb92aca3759a2f7165fb78352e852c /core/variant | |
parent | 2be730a05b7ff221b89c967981f7caee6e164ef0 (diff) | |
download | redot-engine-203d3be200c9b607e5eaba82d9a267813a6700cd.tar.gz |
[Core] Add way to check if a signal has any connections
Added to `Object` and `Signal`
Diffstat (limited to 'core/variant')
-rw-r--r-- | core/variant/callable.cpp | 7 | ||||
-rw-r--r-- | core/variant/callable.h | 1 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index 9dff5c1e91..bb2d0313f6 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -545,6 +545,13 @@ bool Signal::is_connected(const Callable &p_callable) const { return obj->is_connected(name, p_callable); } +bool Signal::has_connections() const { + Object *obj = get_object(); + ERR_FAIL_NULL_V(obj, false); + + return obj->has_connections(name); +} + Array Signal::get_connections() const { Object *obj = get_object(); if (!obj) { diff --git a/core/variant/callable.h b/core/variant/callable.h index 63757d9d6e..e3c940a0e5 100644 --- a/core/variant/callable.h +++ b/core/variant/callable.h @@ -192,6 +192,7 @@ public: Error connect(const Callable &p_callable, uint32_t p_flags = 0); void disconnect(const Callable &p_callable); bool is_connected(const Callable &p_callable) const; + bool has_connections() const; Array get_connections() const; Signal(const Object *p_object, const StringName &p_name); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 178c0bc4ec..63fb5e8d94 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -2121,6 +2121,7 @@ static void _register_variant_builtin_methods_misc() { bind_method(Signal, disconnect, sarray("callable"), varray()); bind_method(Signal, is_connected, sarray("callable"), varray()); bind_method(Signal, get_connections, sarray(), varray()); + bind_method(Signal, has_connections, sarray(), varray()); bind_custom(Signal, emit, _VariantCall::func_Signal_emit, false, Variant); |