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

Make Q_APPLICATION_STATIC behave more friendly when no qt application object exists

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Core: Other
    • None
    • All
    • 2a217aba3 (dev)

    Description

      Q_APPLICATION_STATIC will assert if no application objects exists. This makes it hard to use in cases where we want to transition from Q_GLOBAL_STATIC to Q_APPLICATION_STATIC, and where user code historically can have been used without a Qt application.

      We have this need in Qt Multimedia code, where Qt example code previously demonstrated use of QMediaDevices without first having an application object available. Here, we want to tie the lifetime of internal Qt Multimedia objects to the qt application lifetime to prevent releasing Windows Media Foundation instances as part of static destruction because Microsoft documentation states that it is not supported. See [MFShutdown function (mfapi.h) - Win32 apps | Microsoft Learn|https://learn.microsoft.com/en-us/windows/win32/api/mfapi/nf-mfapi-mfshutdown]

      At the same time, we don't want to break client code that appeared to work as intended by requiring a Qt application object.

      We can argue that an assert in debug is acceptable to make it obvious that user code should be updated. Still, it can break production code if debug builds are being used in products.

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              johanseg Jøger Hansegård
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes