diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/qml/qqmlimport.cpp | 18 | ||||
| -rw-r--r-- | src/qml/qml/qqmlimport_p.h | 5 |
2 files changed, 23 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; } diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h index 2e994fd27f..594eae7bb4 100644 --- a/src/qml/qml/qqmlimport_p.h +++ b/src/qml/qml/qqmlimport_p.h @@ -122,7 +122,12 @@ public: QHashedString prefix; // Used by QQmlImportsPrivate::qualifiedSets + // set to this in unqualifiedSet to indicate that the lists of imports needs + // to be sorted when an inline component import was added + // We can't use flag pointer, as that does not work with QFieldList QQmlImportNamespace *nextNamespace; + bool needsSorting() const; + void setNeedsSorting(bool needsSorting); }; class Q_QML_PRIVATE_EXPORT QQmlImports |
