QML testlib: Do not modify the arguments passed into QGuiApplication.
authorFriedemann Kleint <Friedemann.Kleint@digia.com>
Thu, 6 Mar 2014 15:54:32 +0000 (16:54 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 7 Mar 2014 09:55:20 +0000 (10:55 +0100)
argc/argv passed  into QGuiApplication must match those
of main on Windows due to the special command line parsing.

Task-number: QTBUG-36466
Change-Id: Id722692d2bdc18a6627fdaeffb349b78137ae314
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
src/qmltest/quicktest.cpp

index bb6eec3..b3ed81b 100644 (file)
@@ -208,8 +208,10 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
 #ifdef QT_QMLTEST_WITH_WIDGETS
     bool withWidgets = false;
 #endif
-    int outargc = 1;
     int index = 1;
+    QScopedArrayPointer<char *> testArgV(new char *[argc + 1]);
+    testArgV[0] = argv[0];
+    int testArgC = 1;
     while (index < argc) {
         if (strcmp(argv[index], "-import") == 0 && (index + 1) < argc) {
             imports += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
@@ -227,15 +229,11 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
         } else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
             translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
             index += 2;
-        } else if (outargc != index) {
-            argv[outargc++] = argv[index++];
         } else {
-            ++outargc;
-            ++index;
+            testArgV[testArgC++] = argv[index++];
         }
     }
-    argv[outargc] = 0;
-    argc = outargc;
+    testArgV[testArgC] = 0;
 
     QCoreApplication* app = 0;
     if (!QCoreApplication::instance()) {
@@ -256,7 +254,7 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
     QuickTestResult::setCurrentAppname(argv[0]);
     QuickTestResult::setProgramName(name);
 
-    QuickTestResult::parseArgs(argc, argv);
+    QuickTestResult::parseArgs(testArgC, testArgV.data());
 
 #ifndef QT_NO_TRANSLATION
     QTranslator translator;