From d94dd247ecd6753150dc2a7ef6be4ccb482e9423 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 18 Jul 2019 16:06:26 +0200 Subject: 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 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlimport.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlimport.cpp') 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, QListqmlDirComponents; + 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, QListuri, 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; -- cgit v1.2.3 From f1d213b4039e38bb9ceebaca9167fcb722a0c16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 26 Jul 2019 18:17:27 +0200 Subject: Fix bug in QQmlEngine::setImportPathList() when it had a resource path The bug is really in QQmlImportDatabase::setImportPathList(). It was missing the same conversions that was done in QQmlImportDatabase::addImportPath(), so it failed to use a resource path as a import path because it did not convert ":/foo" to "qrc:/foo". We therefore just use addImportPath() to ensure the paths are converted properly. Before this, several autotests in tests/auto/qml/qqmllanguage failed on Android, since they were calling QQmlEngine::setImportPathList() where the list had resource paths. Task-number: QTBUG-73512 Change-Id: Idc64f5ad20ec665df7cb57ea1c346bc0975c3b0d Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlimport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlimport.cpp') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 5102fb111c..7c9c0da01a 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1958,7 +1958,9 @@ void QQmlImportDatabase::setImportPathList(const QStringList &paths) if (qmlImportTrace()) qDebug().nospace() << "QQmlImportDatabase::setImportPathList: " << paths; - fileImportPath = paths; + fileImportPath.clear(); + for (auto it = paths.crbegin(); it != paths.crend(); ++it) + addImportPath(*it); // Our existing cached paths may have been invalidated clearDirCache(); -- cgit v1.2.3