summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2024-07-25 11:55:53 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-16 17:06:19 +0200
commit5676d398e0d8f542deee5d9096cc7bc1f15bc162 (patch)
treeb7b2c661f7fdaf9710864eb661773fc6861dccf5 /core
parent32f2b851abcbf71848a8e42b11a6a50292527862 (diff)
downloadredot-engine-5676d398e0d8f542deee5d9096cc7bc1f15bc162.tar.gz
Avoid potential crash on signal disconnection
(cherry picked from commit 32b7f835d8fd7466c58ed84a20c46ba9c802e36b)
Diffstat (limited to 'core')
-rw-r--r--core/object/object.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index e4d1a8fc9a..bf24c3a792 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -2097,7 +2097,11 @@ Object::~Object() {
// Disconnect signals that connect to this object.
while (connections.size()) {
Connection c = connections.front()->get();
- bool disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
+ Object *obj = c.callable.get_object();
+ bool disconnected = false;
+ if (likely(obj)) {
+ disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
+ }
if (unlikely(!disconnected)) {
// If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here.
connections.pop_front();