aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-11-06 13:49:57 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-11-20 09:07:21 +0000
commit2b52a997ce3679ac4c94b7c117b0ea11c1523b60 (patch)
tree7e00492fb27479f1efb4590343fc8eff294df86d /src/qml/qml
parenta54e15bc7968a546fc939fc2d166261fd6513d5a (diff)
QML TypeLoader: Sort composite singletons before recursing into them
When recursingly loading further types for composite singletons before sorting them, the order in which the recursively referenced types are loaded is random because the composite singletons are kept in an (unordered) hash. Any sorting after loading the child components doesn't help as the recursive references may depend on the types already loaded at that point. Sorting the composite singletons before starting the recursion does help because it eliminates the source of randomness in the system. Fixes: QTBUG-66976 Change-Id: I0fa1f50b36eba8c73eb8d56b4d5118485ab05f35 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlimport.cpp14
-rw-r--r--src/qml/qml/qqmltypeloader.cpp4
2 files changed, 14 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index bc53b98b5b..ab63489dbf 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -511,6 +511,20 @@ QList<QQmlImports::CompositeSingletonReference> QQmlImports::resolvedCompositeSi
findCompositeSingletons(set, compositeSingletons, baseUrl());
}
+ std::stable_sort(compositeSingletons.begin(), compositeSingletons.end(),
+ [](const QQmlImports::CompositeSingletonReference &lhs,
+ const QQmlImports::CompositeSingletonReference &rhs) {
+ if (lhs.prefix != rhs.prefix)
+ return lhs.prefix < rhs.prefix;
+
+ if (lhs.typeName != rhs.typeName)
+ return lhs.typeName < rhs.typeName;
+
+ return lhs.majorVersion != rhs.majorVersion
+ ? lhs.majorVersion < rhs.majorVersion
+ : lhs.minorVersion < rhs.minorVersion;
+ });
+
return compositeSingletons;
}
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 7480475ca7..cb90af4cf0 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2723,10 +2723,6 @@ void QQmlTypeData::resolveTypes()
}
}
- std::stable_sort(m_compositeSingletons.begin(), m_compositeSingletons.end(), [](const TypeReference &lhs, const TypeReference &rhs){
- return lhs.qualifiedName() < rhs.qualifiedName();
- });
-
for (QV4::CompiledData::TypeReferenceMap::ConstIterator unresolvedRef = m_typeReferences.constBegin(), end = m_typeReferences.constEnd();
unresolvedRef != end; ++unresolvedRef) {