diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-06 12:29:00 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-07 11:25:40 +0000 |
commit | 3633047d812559fc91d6f6324c4677bd886ef7fd (patch) | |
tree | f39250b047dda6a53ffd3c01c24daa80355b0b03 | |
parent | 26fa3d2cef8ec55dfb276e999d41e01e9a846093 (diff) |
QmlCompiler: Use the declared typeinfos rather than the default
... and produce a warning when encountering the default.
This shows us that the qmake build omits some typeinfo entries from
common modules. Add those.
Change-Id: I1c7e87e8a54ef24a6076090e6051eb1c03c09b2a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/imports/labsmodels/qmldir | 1 | ||||
-rw-r--r-- | src/imports/models/qmldir | 1 | ||||
-rw-r--r-- | src/imports/sharedimage/qmldir | 1 | ||||
-rw-r--r-- | src/imports/workerscript/qmldir | 1 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsimporter.cpp | 17 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/OldQmltypes/plugins.qmltypes | 8 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/OldQmltypes/qmldir | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/Things/qmldir | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/oldQmltypes.qml | 4 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 7 |
10 files changed, 41 insertions, 3 deletions
diff --git a/src/imports/labsmodels/qmldir b/src/imports/labsmodels/qmldir index 9c735711c4..2e18f0ae47 100644 --- a/src/imports/labsmodels/qmldir +++ b/src/imports/labsmodels/qmldir @@ -1,3 +1,4 @@ module Qt.labs.qmlmodels plugin labsmodelsplugin +typeinfo plugins.qmltypes classname QtQmlLabsModelsPlugin diff --git a/src/imports/models/qmldir b/src/imports/models/qmldir index 341694a34d..d03af591e9 100644 --- a/src/imports/models/qmldir +++ b/src/imports/models/qmldir @@ -1,4 +1,5 @@ module QtQml.Models optional plugin modelsplugin classname QtQmlModelsPlugin +typeinfo plugins.qmltypes designersupported diff --git a/src/imports/sharedimage/qmldir b/src/imports/sharedimage/qmldir index 079399dc4e..9151c200a8 100644 --- a/src/imports/sharedimage/qmldir +++ b/src/imports/sharedimage/qmldir @@ -1,3 +1,4 @@ module Qt.labs.sharedimage plugin sharedimageplugin +typeinfo plugins.qmltypes classname QtQuickSharedImagePlugin diff --git a/src/imports/workerscript/qmldir b/src/imports/workerscript/qmldir index f1ff798d75..df9464e259 100644 --- a/src/imports/workerscript/qmldir +++ b/src/imports/workerscript/qmldir @@ -1,4 +1,5 @@ module QtQml.WorkerScript optional plugin workerscriptplugin classname QtQmlWorkerScriptPlugin +typeinfo plugins.qmltypes designersupported diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp index 0ea310d64e..a83f344523 100644 --- a/src/qmlcompiler/qqmljsimporter.cpp +++ b/src/qmlcompiler/qqmljsimporter.cpp @@ -105,8 +105,21 @@ QQmlJSImporter::Import QQmlJSImporter::readQmldir(const QString &path) for (auto it = qmlComponents.begin(), end = qmlComponents.end(); it != end; ++it) result.objects.insert(it.key(), it.value()); - if (!reader.plugins().isEmpty() && QFile::exists(path + SlashPluginsDotQmltypes)) - readQmltypes(path + SlashPluginsDotQmltypes, &result.objects); + const auto typeInfos = reader.typeInfos(); + for (const auto &typeInfo : typeInfos) { + const QString typeInfoPath = QFileInfo(typeInfo).isRelative() + ? path + u'/' + typeInfo : typeInfo; + readQmltypes(typeInfoPath, &result.objects); + } + + if (typeInfos.isEmpty() && !reader.plugins().isEmpty()) { + const QString defaultTypeInfoPath = path + SlashPluginsDotQmltypes; + if (QFile::exists(defaultTypeInfoPath)) { + m_warnings.append(QStringLiteral("typeinfo not declared in qmldir file: ") + + defaultTypeInfoPath); + readQmltypes(defaultTypeInfoPath, &result.objects); + } + } const auto scripts = reader.scripts(); for (const auto &script : scripts) { diff --git a/tests/auto/qml/qmllint/data/OldQmltypes/plugins.qmltypes b/tests/auto/qml/qmllint/data/OldQmltypes/plugins.qmltypes new file mode 100644 index 0000000000..eab91f6723 --- /dev/null +++ b/tests/auto/qml/qmllint/data/OldQmltypes/plugins.qmltypes @@ -0,0 +1,8 @@ +import QtQuick.tooling 1.2 +Module { + Component { + name: "Frame" + exports: ["OldQmltypes/Frame 1.0"] + exportMetaObjectRevisions: [0] + } +} diff --git a/tests/auto/qml/qmllint/data/OldQmltypes/qmldir b/tests/auto/qml/qmllint/data/OldQmltypes/qmldir new file mode 100644 index 0000000000..374a533bbc --- /dev/null +++ b/tests/auto/qml/qmllint/data/OldQmltypes/qmldir @@ -0,0 +1,2 @@ +module OldQmltypes +plugin foobar diff --git a/tests/auto/qml/qmllint/data/Things/qmldir b/tests/auto/qml/qmllint/data/Things/qmldir index d91d4afc92..554f75d313 100644 --- a/tests/auto/qml/qmllint/data/Things/qmldir +++ b/tests/auto/qml/qmllint/data/Things/qmldir @@ -1,5 +1,5 @@ module Things Something 1.0 SomethingElse.qml -plugin doesNotExistPlugin +typeinfo plugins.qmltypes depends QtQuick 2.0 import QtQml diff --git a/tests/auto/qml/qmllint/data/oldQmltypes.qml b/tests/auto/qml/qmllint/data/oldQmltypes.qml new file mode 100644 index 0000000000..f33d4d90fe --- /dev/null +++ b/tests/auto/qml/qmllint/data/oldQmltypes.qml @@ -0,0 +1,4 @@ +import OldQmltypes 1.0 + +Frame { +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 75938161b5..1b77e941ab 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -51,6 +51,7 @@ private Q_SLOTS: void testUnknownCausesFail(); void directoryPassedAsQmlTypesFile(); + void oldQmltypes(); private: QString runQmllint(const QString &fileToLint, @@ -133,6 +134,12 @@ void TestQmllint::directoryPassedAsQmlTypesFile() "Expected error to contain \"%1\", but it didn't: %2").arg(expectedError, errorMessages))); } +void TestQmllint::oldQmltypes() +{ + const QString errors = runQmllint("oldQmltypes.qml", true); + QVERIFY(errors.contains(QStringLiteral("Warning: typeinfo not declared in qmldir file"))); +} + void TestQmllint::dirtyQmlCode_data() { QTest::addColumn<QString>("filename"); |