Details
-
Bug
-
Resolution: Won't Do
-
P4: Low
-
None
-
5.12.0
-
None
Description
The documentation of QObject::deleteLater states:
"Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called."
This is implemented by comparing the loop level, when the DeferredDelete is posted with when it gets processed. Unfortunately the loop level is also affected by QCoreApplication::sendEvent, what leads to a wrong level added to the event in terms of the check.
Attached you find a small demo, that leads to deleting the object by starting an event loop.
As QCoreApplication::sendEvent is used internally by Qt ( f.e QQuickWindow ) it is no option to use postEvent instead.
The only workaround I'm aware of is to record the loop level in MyApplication::notify and to implement the blocking/reposting of DeferredDeletes myself - something I had to do in early Qt versions.
Guess this problem has been there for all versions >= 5.0
Attachments
For Gerrit Dashboard: QTBUG-73432 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
251893,3 | Doc: update the note about nested deleteLater() | 5.12 | qt/qtbase | Status: MERGED | +2 | 0 |