Skip to content

Commit e185fc3

Browse files
committed
fixed problematic self deletion without having the GIL and while iterating the loop
1 parent 50c3306 commit e185fc3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/PythonQtSignalReceiver.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,24 @@ int PythonQtSignalReceiver::qt_metacall(QMetaObject::Call c, int id, void **argu
265265
QObject::qt_metacall(c, id, arguments);
266266
}
267267

268-
Q_FOREACH(const PythonQtSignalTarget& t, _targets) {
268+
bool shouldDelete = false;
269+
for(const PythonQtSignalTarget& t : _targets) {
269270
if (t.slotId() == id) {
270271
t.call(arguments);
271272
// if the signal is the last destroyed signal, we delete ourselves
272273
int sigId = t.signalId();
273274
if ((sigId == _destroyedSignal1Id) || (sigId == _destroyedSignal2Id)) {
274275
_destroyedSignalCount--;
275276
if (_destroyedSignalCount == 0) {
276-
delete this;
277+
shouldDelete = true;
277278
}
278279
}
279280
break;
280281
}
281282
}
283+
if (shouldDelete) {
284+
delete this;
285+
}
282286
return 0;
283287
}
284288

0 commit comments

Comments
 (0)