From fa376883f0ce503e0346b1bb680a60df0dab52de Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 28 Nov 2023 16:18:48 +0100 Subject: [PATCH] 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 --- src/libs/qmljs/qmljsinterpreter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 63e009607b9..9448ef39b01 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -1485,8 +1485,10 @@ QList 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)) {