Merge pull request #94666 from RandomShaper/fix_tangled_obj_clear_crash
Avoid potential crash on signal disconnection
This commit is contained in:
commit
86212c1fe4
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue