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

deleteLater from showEvent (before app.exec) is never processed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.3.0 Beta1
    • Core: Event loop
    • None
    • Linux

    Description

      The documentation for deleteLater says:

      If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started.

      This is true, but only if the QThreadData::loopLevel was equal to zero when deleteLater was called. If called from an event handler (e.g. a showEvent), loopLevel is 1, so the main event loop will refuse to process that DeferredDelete event (it only processes them for calls from higher nesting levels, such as any events handled by the main loop, or for events with loop level 0).

      The attached testcase shows the issue.
      You can see that the destructor of the job isn't called (and for that reason the window, which checks for alive jobs, cannot be closed).
      A workaround is included (in a comment) : flushing DeferredDelete before entering app.exec(). This makes me think that this could be the fix, doing that within Qt?

      Attachments

        1. taglistjobtest.cpp
          0.7 kB
          David Faure
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            dfaure_kdab David Faure
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes