From c87b4abdc09f3ef522941d4f2908792165e2cb4c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 26 Jan 2021 09:14:05 +0100 Subject: 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 --- src/qmlcompiler/qqmljsimportvisitor.cpp | 2 +- tests/auto/qml/qmllint/data/overridescript.qml | 7 +++++++ tests/auto/qml/qmllint/data/testlogger.js | 1 + tests/auto/qml/qmllint/tst_qmllint.cpp | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qmllint/data/overridescript.qml create mode 100644 tests/auto/qml/qmllint/data/testlogger.js 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() -- cgit v1.2.3