summaryrefslogtreecommitdiffstats
path: root/core/object/object.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2023-04-11 17:20:03 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2023-04-11 17:27:39 +0200
commit2f4168daeba6e70de51bb2abbad1cc0b0bc54fe4 (patch)
treed2178d64ff87b3481eb153ba41cf82540685fec6 /core/object/object.cpp
parent59b8c700072c6bb25b0f1f95c40e54941d941383 (diff)
downloadredot-engine-2f4168daeba6e70de51bb2abbad1cc0b0bc54fe4.tar.gz
Fix edge cases of object lifetime when signals involved
Diffstat (limited to 'core/object/object.cpp')
-rw-r--r--core/object/object.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 39cae7c5bd..2e1ea9ef5f 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -1013,6 +1013,10 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
return ERR_UNAVAILABLE;
}
+ // If this is a ref-counted object, prevent it from being destroyed during signal emission,
+ // which is needed in certain edge cases; e.g., https://github.com/godotengine/godot/issues/73889.
+ Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
+
List<_ObjectSignalDisconnectData> disconnect_data;
//copy on write will ensure that disconnecting the signal or even deleting the object will not affect the signal calling.