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

Invalid QApplication construction with argc=0

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • None
    • 6.4.0, 6.5.0 Beta1
    • Active Qt
    • Windows 10 21H2 (64bit). Visual Studio 2022.
    • Windows
    • a1b49152e (dev), 38a2fa5e8 (6.5)

    Description

      ActiveQt does in certain scenarios create QApplication with argc=0, which is invalid according to the doc. The pattern is furthermore causing problems for parameter-parsing code that assumes that the first argument will always be the executable name, like QtWebEngine (see QTBUG-110157).

      Suggested fix

      Update activeqt/control/qaxserverbase.cpp (line 886) and qtactiveqt/src/activeqt/control/qaxserver.cpp (line 442 & 1149) to instead pass all command-line arguments using the sample code below.

      Example of how QApplication can be initialized using  __argc & __argv:

      QApplication(__argc, __argv);
      

      Alternative Win32 code for retrieving all command-line arguments:

      int argc = 0;
      wchar_t **argv = CommandLineToArgvW(GetCommandLineW(), &argc);
      LocalFree(argv);
      // TODO: Convert argv strings to ASCII
      

      Attachments

        For Gerrit Dashboard: QTBUG-110158
        # Subject Branch Project Status CR V

        Activity

          People

            owolff Oliver Wolff
            forderud Fredrik Orderud
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes