diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-02-19 13:19:09 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-03-16 09:51:21 +0100 |
commit | b5f4b92b36f4957452cb0df7ead79d270bc568b5 (patch) | |
tree | a081231d01e68741e32e28a43d97ec7082fbd2dc /src/qml/qml/qqmlimport.cpp | |
parent | f9ce66f1218beba5e88ae2137520a1516e40007f (diff) |
Prefer Inline Components over any other imported name
After processing all other imports, there might be other imports both
in front and behind of the inline component imports in the import list.
To avoid having to search for them, we sort the list so that they are
in front.
Fixes: QTBUG-82302
Change-Id: I9f6deb03608b1ebd0cbe0eddd1a1e5d39837a783
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlimport.cpp')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 2a6ede83c7..c3f6a9057d 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -988,6 +988,12 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS if (!typeRecursionDetected) typeRecursionDetected = &localTypeRecursionDetected; + if (needsSorting()) { + std::stable_sort(imports.begin(), imports.end(), [](QQmlImportInstance *left, QQmlImportInstance *) { + return left->isInlineComponent; + }); + setNeedsSorting(false); + } for (int i=0; i<imports.count(); ++i) { const QQmlImportInstance *import = imports.at(i); if (import->resolveType(typeLoader, type, vmajor, vminor, type_return, base, @@ -1047,6 +1053,17 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS return false; } +bool QQmlImportNamespace::needsSorting() const +{ + return nextNamespace == this; +} + +void QQmlImportNamespace::setNeedsSorting(bool needsSorting) +{ + Q_ASSERT(nextNamespace == this || nextNamespace == nullptr); + nextNamespace = needsSorting ? this : nullptr; +} + QQmlImportsPrivate::QQmlImportsPrivate(QQmlTypeLoader *loader) : ref(1), typeLoader(loader) { } @@ -1760,6 +1777,7 @@ bool QQmlImports::addInlineComponentImport(QQmlImportInstance *const importInsta importInstance->minversion = 0; importInstance->containingType = containingType; d->unqualifiedset.imports.push_back(importInstance); + d->unqualifiedset.setNeedsSorting(true); return true; } |