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 From cb991e69c04726fb46ec8c03d966dcbf159e2fe0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Jan 2016 14:02:34 +0100 Subject: testcon: Add options for application attributes. Make it possible to set Qt::AA_DisableHighDpiScaling and Qt::AA_DontCreateNativeWidgetSiblings. Task-number: QTBUG-50206 Change-Id: Ib5f0e9f29a78b22c99edfef3b6687482150d9896 Reviewed-by: Joerg Bornemann --- tools/testcon/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/testcon/main.cpp b/tools/testcon/main.cpp index 863a9e4..ac860bd 100644 --- a/tools/testcon/main.cpp +++ b/tools/testcon/main.cpp @@ -49,6 +49,15 @@ QAXFACTORY_DEFAULT(MainWindow, QT_USE_NAMESPACE +static bool isOptionSet(int argc, char *argv[], const char *option) +{ + for (int i = 1; i < argc; ++i) { + if (!qstrcmp(argv[i], option)) + return true; + } + return false; +} + static void redirectDebugOutput(QtMsgType, const QMessageLogContext &, const QString &msg) { if (MainWindow *mainWindow = MainWindow::instance()) @@ -57,6 +66,11 @@ static void redirectDebugOutput(QtMsgType, const QMessageLogContext &, const QSt int main( int argc, char **argv ) { + if (isOptionSet(argc, argv, "--no-scaling")) + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + if (isOptionSet(argc, argv, "--no-native-siblings")) + QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + QApplication app( argc, argv ); QCoreApplication::setApplicationName(QLatin1String("TestCon")); QCoreApplication::setOrganizationName(QLatin1String("QtProject")); @@ -72,6 +86,12 @@ int main( int argc, char **argv ) QCommandLineOption noMessageHandlerOption(QLatin1String("no-messagehandler"), QLatin1String("Suppress installation of the message handler.")); parser.addOption(noMessageHandlerOption); + QCommandLineOption noScalingDummy(QLatin1String("no-scaling"), + QLatin1String("Set Qt::AA_DisableHighDpiScaling.")); + parser.addOption(noScalingDummy); + QCommandLineOption noNativeSiblingsDummy(QLatin1String("no-native-siblings"), + QLatin1String("Set Qt::AA_DontCreateNativeWidgetSiblings.")); + parser.addOption(noNativeSiblingsDummy); parser.addPositionalArgument(QLatin1String("clsid/file"), QLatin1String("The clsid/file to show.")); parser.process(app); -- cgit v1.2.3