Skip to content

Commit

Permalink
Avoid potential crash on signal disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomShaper committed Aug 19, 2024
1 parent 7a4a6fb commit 32b7f83
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 32b7f83

Please sign in to comment.