summaryrefslogtreecommitdiffstats
path: root/core/variant/callable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant/callable.cpp')
-rw-r--r--core/variant/callable.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index 9dff5c1e91..5ce90cd8ff 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -315,31 +315,32 @@ bool Callable::operator<(const Callable &p_callable) const {
}
void Callable::operator=(const Callable &p_callable) {
+ CallableCustom *cleanup_ref = nullptr;
if (is_custom()) {
if (p_callable.is_custom()) {
if (custom == p_callable.custom) {
return;
}
}
-
- if (custom->ref_count.unref()) {
- memdelete(custom);
- custom = nullptr;
- }
+ cleanup_ref = custom;
+ custom = nullptr;
}
if (p_callable.is_custom()) {
method = StringName();
- if (!p_callable.custom->ref_count.ref()) {
- object = 0;
- } else {
- object = 0;
+ object = 0;
+ if (p_callable.custom->ref_count.ref()) {
custom = p_callable.custom;
}
} else {
method = p_callable.method;
object = p_callable.object;
}
+
+ if (cleanup_ref != nullptr && cleanup_ref->ref_count.unref()) {
+ memdelete(cleanup_ref);
+ }
+ cleanup_ref = nullptr;
}
Callable::operator String() const {
@@ -545,6 +546,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) {