diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-21 12:30:20 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-21 23:26:21 +0000 |
commit | 4099a51dd5a9564e580a0f3676a0a850bd4ec26d (patch) | |
tree | 602488bbf8d86906202040ef704bc11020501656 | |
parent | 415ef1504349f08d0c0868995de3b43ef6c027f1 (diff) |
QmlCompiler: Add C++ name also for types with no export candidates
Even if the type is only exported in a newer version of the module, we
still need to know about it in an earlier version, in order to resolve
base types.
Change-Id: Ibc7940308e3c4aaebf9871a159e1d85f43cd7693
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 24e5b9090b513861e77dcb17b8e4d75f0bdf8651)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qmlcompiler/qqmljsimporter.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/unexportedCppBase.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp index a0d4a78fc9..407f128810 100644 --- a/src/qmlcompiler/qqmljsimporter.cpp +++ b/src/qmlcompiler/qqmljsimporter.cpp @@ -314,8 +314,12 @@ void QQmlJSImporter::processImport(const QQmlJSScope::Import &importDescription, seenExports[qmlName].append(valExport); } - if (bestExport.isValid()) - types->cppNames.insert(cppName, { val.scope, bestExport.revision() }); + types->cppNames.insert( + cppName, { + val.scope, + bestExport.isValid() ? bestExport.revision() : QTypeRevision::zero() + } + ); }; if (!importDescription.prefix().isEmpty()) diff --git a/tests/auto/qml/qmllint/data/unexportedCppBase.qml b/tests/auto/qml/qmllint/data/unexportedCppBase.qml new file mode 100644 index 0000000000..c8530fd865 --- /dev/null +++ b/tests/auto/qml/qmllint/data/unexportedCppBase.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property QtObject i: Image {} +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index b061262fee..27af9beed6 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -967,6 +967,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("matchByName") << QStringLiteral("matchByName.qml"); QTest::newRow("cppPropertyChangeHandlers") << QStringLiteral("goodCppPropertyChangeHandlers.qml"); + QTest::newRow("unexportedCppBase") << QStringLiteral("unexportedCppBase.qml"); } void TestQmllint::cleanQmlCode() |