QmlJSCheck: Ensure that ::createObjectsForImport always works correctly

If ::createObjectsForImport is called twice, then
m_objectsByQualifiedName already contains the type and an empty list is
returned. The returned list is used for the prototype lookup and
in this case the import is empty and the prototype cannot be found.
This happened for QtQuick3D.Effect when used from QtQuick3D.Effects in some
cases. There is a race condition. The second call to ::::createObjectsForImport
is quite rare.

Task-number: QDS-11069
Change-Id: I6dfe152224172d0d626625d24a53f36d4219372f
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2023-11-28 16:18:48 +01:00
parent c5f023751f
commit fa376883f0

View File

@@ -1485,8 +1485,10 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
// if it already exists, skip
const QString key = qualifiedName(package, fmo->className(), version);
if (m_objectsByQualifiedName.contains(key))
if (m_objectsByQualifiedName.contains(key)) {
exportedObjects.insert(key, m_objectsByQualifiedName.value(key));
continue;
}
ComponentVersion cppVersion;
for (const FakeMetaObject::Export &bestExport : std::as_const(bestExports)) {