diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-07-18 16:06:26 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-07-23 16:38:07 +0200 |
commit | d94dd247ecd6753150dc2a7ef6be4ccb482e9423 (patch) | |
tree | 198ab0b2ae3aa7ee4476dcf849e005dc7065e35d /src | |
parent | 1dad2029a5bdbc40b244f72f995d70d27ed98e62 (diff) |
Do not search for Singletons from more recent versions
This would break importing older versions of a module, as we would try
to locate a singleton which does not exist in this version.
Fixes: QTBUG-77102
Change-Id: I78be1ec111d2be26a14b2a94bbf743cf6238cddd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 5a1364473e..ba8dce4b6e 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -465,9 +465,18 @@ void findCompositeSingletons(const QQmlImportNamespace &set, QList<QQmlImports:: const QQmlDirComponents &components = import->qmlDirComponents; + const int importMajorVersion = import->majversion; + const int importMinorVersion = import->minversion; + auto shouldSkipSingleton = [importMajorVersion, importMinorVersion](int singletonMajorVersion, int singletonMinorVersion) -> bool { + return importMajorVersion != -1 && + (singletonMajorVersion > importMajorVersion || (singletonMajorVersion == importMajorVersion && singletonMinorVersion > importMinorVersion)); + }; + ConstIterator cend = components.constEnd(); for (ConstIterator cit = components.constBegin(); cit != cend; ++cit) { if (cit->singleton && excludeBaseUrl(import->url, cit->fileName, baseUrl.toString())) { + if (shouldSkipSingleton(cit->majorVersion, cit->minorVersion)) + continue; QQmlImports::CompositeSingletonReference ref; ref.typeName = cit->typeName; ref.prefix = set.prefix; @@ -478,7 +487,9 @@ void findCompositeSingletons(const QQmlImportNamespace &set, QList<QQmlImports:: } if (QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion)) { - module->walkCompositeSingletons([&resultList, &set](const QQmlType &singleton) { + module->walkCompositeSingletons([&resultList, &set, &shouldSkipSingleton](const QQmlType &singleton) { + if (shouldSkipSingleton(singleton.majorVersion(), singleton.minorVersion())) + return; QQmlImports::CompositeSingletonReference ref; ref.typeName = singleton.elementName(); ref.prefix = set.prefix; |