Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73432

Invalid processing of DeferredDelete Events

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P4: Low
    • None
    • 5.12.0
    • Core: Event loop
    • None
    • All

    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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            uwe Uwe Rathmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes