Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.5.1
-
None
Description
When deleteLater() is called from the QEvent destructor (of an event delivered to the main loop), the object won't be delivered until the event loop exits.
The bug exists at least until Qt 5.5.1 (but probably also in current versions).
The attached test case should print:
X::X() X::~X() Calling o->deleteLater() Object is being destroyed timer expires, objExists = false
but instead it prints:
X::X() X::~X() Calling o->deleteLater() timer expires, objExists = true object has not been destroyed Object is being destroyed
Note that X::~X() is executed from the destructor for the event which is used to deliver the queued signal from Obj::fooSig to Obj::fooSlot. This destructor is called from QCoreApplicationPrivate::sendPostedEvents when the QScopedPointer is destroyed, and not from QCoreApplication::sendEvent/QCoreApplication::notifyInternal like almost all other user code is. As far as I can see this means that the loop level counter is not incremented and the QDeferredDeleteEvent records a too low loop level.