From bb9ee3a9794b73bb16a4cb0f445fe773e6af79e2 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Wed, 27 Jan 2016 00:36:29 +0100 Subject: Change "argc" variable to have static lifetime. Required, since the QApplication object contains a reference back to "argc". The lifetime of the QApplication object exceeds "argc" on the stack. This in turn causes QApplication to see a corrupted "argc" values later in the function. This fixes a nasty crash during IDC-based IDL generation & DLL registration that was only observed in release build post-build events with VS2012. Change-Id: Ie8e404060deccadc75560748ad7071b41425cf79 Reviewed-by: Friedemann Kleint --- src/activeqt/control/qaxserver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index 1703765..74b7c57 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -248,7 +248,7 @@ HRESULT UpdateRegistry(BOOL bRegister) // we try to create the ActiveX widgets later on... bool delete_qApp = false; if (!qApp) { - int argc = 0; + 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, 0); delete_qApp = true; } @@ -1147,7 +1147,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) // dummy application to create widgets bool delete_qApp = false; if (!qApp) { - int argc=0; + 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, 0); delete_qApp = true; } -- cgit v1.2.3