diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-03-25 16:22:03 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-03 13:54:29 +0200 |
commit | cf06b028f71fb80616be7fbb3ef3aaf7d5474eca (patch) | |
tree | fb5471c913a09efe4900a2c11bbf7fa33598aa72 /src/qmltest/quicktest.cpp | |
parent | 8d172f1f3836f9f528ad85b4707582e44154450f (diff) |
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 <Friedemann.Kleint@digia.com>
Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'src/qmltest/quicktest.cpp')
-rw-r--r-- | src/qmltest/quicktest.cpp | 40 |
1 files 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<char *> 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]); |