From cf06b028f71fb80616be7fbb3ef3aaf7d5474eca Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 25 Mar 2014 16:22:03 +0100 Subject: QtQuick test: Do not complain about Qt specific arguments Commit 1ca5e82cccae0 caused a regression for Qt arguments like -qmlsjsdebugger=xxx . These are automatically removed from argv by QCoreApplication, but since we copied argv before instantiating QCoreApplication this didn't have any effect. Fix this by moving Q[Core]Application instantiation again before the parsing and copying of testlib-specific arguments. Task-number: QTBUG-37793 Change-Id: Ief41640b6cf3251f700a5d24d2e1141233a3888f Reviewed-by: Friedemann Kleint Reviewed-by: Liang Qi --- src/qmltest/quicktest.cpp | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index b3ed81b939..3a7b13fd18 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -198,6 +198,29 @@ bool qWaitForSignal(QObject *obj, const char* signal, int timeout = 5000) int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir) { + // Peek at arguments to check for '-widgets' argument +#ifdef QT_QMLTEST_WITH_WIDGETS + bool withWidgets = false; + for (int index = 1; index < argc; ++index) { + if (strcmp(argv[index], "-widgets") == 0) { + withWidgets = true; + break; + } + } +#endif + + QCoreApplication *app = 0; + if (!QCoreApplication::instance()) { +#ifdef QT_QMLTEST_WITH_WIDGETS + if (withWidgets) + app = new QApplication(argc, argv); + else +#endif + { + app = new QGuiApplication(argc, argv); + } + } + // Look for QML-specific command-line options. // -import dir Specify an import directory. // -input dir Specify the input directory for test cases. @@ -205,9 +228,6 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD QStringList imports; QString testPath; QString translationFile; -#ifdef QT_QMLTEST_WITH_WIDGETS - bool withWidgets = false; -#endif int index = 1; QScopedArrayPointer testArgV(new char *[argc + 1]); testArgV[0] = argv[0]; @@ -235,20 +255,6 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD } testArgV[testArgC] = 0; - QCoreApplication* app = 0; - if (!QCoreApplication::instance()) { -#ifdef QT_QMLTEST_WITH_WIDGETS - if (withWidgets) - app = new QApplication(argc, argv); - else -#endif - { - app = new QGuiApplication(argc, argv); - } - } - - // Parse the command-line arguments. - // Setting currentAppname and currentTestObjectName (via setProgramName) are needed // for the code coverage analysis. Must be done before parseArgs is called. QuickTestResult::setCurrentAppname(argv[0]); -- cgit v1.2.3