aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-26 09:14:05 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-26 13:53:41 +0100
commitc87b4abdc09f3ef522941d4f2908792165e2cb4c (patch)
treeaa1908383f87e08aac8c5c2f409bb940fe99dc2a
parented59dfeb706242d314aa21889ad0f5a7e028069f (diff)
QmlCompiler: Return after importing a script
If we don't return there, the newly imported script is promptly overwritten by an invalid module. Change-Id: I788a7275e2c190a20c176da35f5c76ac9f6ad02b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp2
-rw-r--r--tests/auto/qml/qmllint/data/overridescript.qml7
-rw-r--r--tests/auto/qml/qmllint/data/testlogger.js1
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
4 files changed, 10 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index d5b5acd06b..5d858229dd 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -320,7 +320,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiImport *import)
const auto scope = m_importer->importFile(path.canonicalFilePath());
m_rootScopeImports.insert(prefix.isEmpty() ? scope->internalName() : prefix, scope);
}
-
+ return true;
}
QString path {};
diff --git a/tests/auto/qml/qmllint/data/overridescript.qml b/tests/auto/qml/qmllint/data/overridescript.qml
new file mode 100644
index 0000000000..b85333b95f
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/overridescript.qml
@@ -0,0 +1,7 @@
+import QtQml
+import QtTest
+import "testlogger.js" as TestLogger
+
+QtObject {
+ objectName: TestLogger.log_start_test()
+}
diff --git a/tests/auto/qml/qmllint/data/testlogger.js b/tests/auto/qml/qmllint/data/testlogger.js
new file mode 100644
index 0000000000..c30bc3dd58
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/testlogger.js
@@ -0,0 +1 @@
+function log_start_test() { return true; }
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 994bb2cea0..895953c2f7 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -336,6 +336,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("optionalImport") << QStringLiteral("optionalImport.qml");
QTest::newRow("goodAliasObject") << QStringLiteral("goodAliasObject.qml");
QTest::newRow("jsmoduleimport") << QStringLiteral("jsmoduleimport.qml");
+ QTest::newRow("overridescript") << QStringLiteral("overridescript.qml");
}
void TestQmllint::cleanQmlCode()