From a1b49152e7a46da955515b8d38d86b947d78bd26 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Thu, 19 Jan 2023 15:30:45 +0100 Subject: 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. Pick-to: 6.5 Task-number: QTBUG-110158 Change-Id: Ib8e6ac7a1c24cfabfdafe8489fe8b8c4765753fd Reviewed-by: Oliver Wolff --- src/activeqt/control/qaxserver.cpp | 6 ++---- 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); -- cgit v1.2.1