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

Make it possible for most derived QCoreApplication subclass to call qt_call_post_routines

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2
    • Core: Event loop
    • None

    Description

      In Qt it is a pattern that QCoreApplication, QGuiApplication and QApplication all call qt_call_post_routines() at the top of their destructor. This is essential to ensure that the post routines are invoked while the event dispatcher is still running or in more general terms, while it is still valid to send events. If an application subclasses one of the these three Qt-provided application classes and override QCoreApplication::notify() then it becomes subsceptible to a race condition at exit, where resources that are scheduled for clean up via qAddPostRoutine() are still alive after the SomeApplicationSubClass destructor has executed, but the Q*Application destructor has not. This must not be allowed because events send during this window will invoke SomeApplicationSubClass::notify() on a partially destroyed object. If the SomeApplicationSubClass::notify() method touches SomeApplicationSubClass data members this is likely to lead to a crash in practice too.

      qt_call_post_routines() should be public API or there should be a public API added that calls it, e.g protected QCoreApplication::callPostRoutines(), and it should be documented that subclasses of QCoreApplication should call it in their destructor.

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            ts Thomas Sondergaard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes