diff options
author | Fredrik Orderud <fredrik.orderud@ge.com> | 2023-01-19 15:30:45 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-23 14:17:14 +0000 |
commit | 38a2fa5e890ae472d69e9c9856a2cc3fab12fef7 (patch) | |
tree | d76067a318c972a1e2792dca7108eca1631aedf8 | |
parent | be78dcfcae3765c3b978f45ca65b90af8434c273 (diff) | |
download | qtactiveqt-38a2fa5e890ae472d69e9c9856a2cc3fab12fef7.tar.gz |
Fix invalid QApplication construction
QApplication construction with argc=0 is incorrect according to the doc.
The construction pattern is furthermore causing problems in QtWebEngine,
which is expecting the executable name as first command-line arguments
as reported in QTBUG-110157.
Fix problem by using the Microsoft-specific __argc and __argv globals.
This ensures that the actual command-line arguments are used for
QApplication construction.
Task-number: QTBUG-110158
Change-Id: Ib8e6ac7a1c24cfabfdafe8489fe8b8c4765753fd
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit a1b49152e7a46da955515b8d38d86b947d78bd26)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/activeqt/control/qaxserver.cpp | 6 | ||||
-rw-r--r-- | src/activeqt/control/qaxserverbase.cpp | 3 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index d7ea1d2..aa4b951 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -438,8 +438,7 @@ HRESULT UpdateRegistry(bool bRegister, bool perUser) // we try to create the ActiveX widgets later on... bool delete_qApp = false; if (!qApp) { - static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame - (void)new QApplication(argc, nullptr); + (void)new QApplication(__argc, __argv); delete_qApp = true; } @@ -1145,8 +1144,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) // dummy application to create widgets bool delete_qApp = false; if (!qApp) { - static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame - (void)new QApplication(argc, nullptr); + (void)new QApplication(__argc, __argv); delete_qApp = true; } diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index ac52583..0800cd9 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -882,8 +882,7 @@ HRESULT QClassFactory::CreateInstanceHelper(IUnknown *pUnkOuter, REFIID iid, voi // Make sure a QApplication instance is present (inprocess case) if (!qApp) { qax_ownQApp = true; - static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame - new QApplication(argc, nullptr); + new QApplication(__argc, __argv); } QGuiApplication::setQuitOnLastWindowClosed(false); |