Skip to content

Commit 32b7f83

Browse files
committed
Avoid potential crash on signal disconnection
1 parent 7a4a6fb commit 32b7f83

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/object/object.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,11 @@ Object::~Object() {
20972097
// Disconnect signals that connect to this object.
20982098
while (connections.size()) {
20992099
Connection c = connections.front()->get();
2100-
bool disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
2100+
Object *obj = c.callable.get_object();
2101+
bool disconnected = false;
2102+
if (likely(obj)) {
2103+
disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
2104+
}
21012105
if (unlikely(!disconnected)) {
21022106
// If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here.
21032107
connections.pop_front();

0 commit comments

Comments
 (0)