qml-tool: Treat all arguments passed after "--" as positional
The argument "-a" passed after "--" was being interpreted as the -a option of the qml tool itself instead of being passed along to the qml program as a positional argument. Fixes: QTBUG-136120 Pick-to: 6.9 6.8 6.5 Change-Id: I602aea84e4766abeb47adce0f739f12315a70b24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
9bebb7017b
commit
6ac4833a51
|
@ -9,6 +9,8 @@
|
|||
#include <QtGui/qpa/qplatformintegration.h>
|
||||
#include <QtQuickTestUtils/private/qmlutils_p.h>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
|
||||
Q_LOGGING_CATEGORY(lcQml, "qt.qml.tests");
|
||||
|
||||
class tst_qml : public QQmlDataTest
|
||||
|
@ -22,6 +24,7 @@ private slots:
|
|||
void nonWindow();
|
||||
void itemAndWindowGeometry_data();
|
||||
void itemAndWindowGeometry();
|
||||
void extraPositionalArguments();
|
||||
|
||||
private:
|
||||
QString qmlPath;
|
||||
|
@ -175,6 +178,38 @@ void tst_qml::itemAndWindowGeometry()
|
|||
QCOMPARE(contentSize, expectedContentSize);
|
||||
}
|
||||
|
||||
void tst_qml::extraPositionalArguments()
|
||||
{
|
||||
QProcess qml;
|
||||
QStringList args;
|
||||
|
||||
QTemporaryFile f;
|
||||
QVERIFY(f.open());
|
||||
QVERIFY(f.write(R"(import QtQml
|
||||
|
||||
QtObject {
|
||||
Component.onCompleted: {
|
||||
let s = ""
|
||||
for (let i = 2; i < Qt.application.arguments.length; ++i)
|
||||
s += Qt.application.arguments[i].substring(1)
|
||||
console.log(s)
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
)"));
|
||||
f.flush();
|
||||
|
||||
args << f.fileName();
|
||||
args << "--";
|
||||
for (char c = 'a'; c <= 'z'; ++c)
|
||||
args << u'-' + QString(c);
|
||||
|
||||
qml.start(qmlPath, args);
|
||||
QVERIFY(qml.waitForFinished());
|
||||
QVERIFY(qml.exitStatus() == QProcess::NormalExit && qml.exitCode() == 0);
|
||||
QVERIFY(qml.readAllStandardError().contains("abcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qml)
|
||||
|
||||
#include <tst_qml.moc>
|
||||
|
|
|
@ -318,6 +318,9 @@ static void getAppFlags(int argc, char **argv)
|
|||
{
|
||||
#ifdef QT_GUI_LIB
|
||||
for (int i=0; i<argc; i++) {
|
||||
if (strcmp(argv[i], "--"))
|
||||
return; // After "--", arguments are interpreted as positional and not as options.
|
||||
|
||||
if (!strcmp(argv[i], "--apptype") || !strcmp(argv[i], "-a") || !strcmp(argv[i], "-apptype")) {
|
||||
applicationType = QmlApplicationTypeUnknown;
|
||||
if (i+1 < argc) {
|
||||
|
|
Loading…
Reference in New Issue