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

QCoreApplication static methods update




      Qt user has following suggestion:
      Lots of QCoreApplication's static methods are actually not statically callable.
      For instance, when you call QCoreApplication::applicationDirPath() before creating instance, you will get an warning and empty string.
      This is not desirable behavior in two aspects.

      First of all, if the result depends on instance, it should be non-static method. Marking it as static makes people confused. I don't know why this is not changed when bumping Qt 6 from Qt 5, I know it is not possible to change static-ness for now because of API/ABI compatibility. This should be reserved to be fixed for Qt 7.

      Second of all, actually some of such static methods can be implemented truly statically. For instance, QCoreApplication::applicationFilePath() should not depend on instance. On Linux/Unix, it will just read and parse /proc file. On Windows, GetModuleFileName() with null HMODULE will give you current process's executable path. If you want to cache the result, you can just use local scoped static variable instead of the entire application instance. This kind of static methods can be fixed without breaking compatibility, so it would be nice to see such improvement in near release.


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



            thiago Thiago Macieira
            tero.pelkonen Tero Pelkonen
            0 Vote for this issue
            3 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes