diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2023-11-28 16:18:48 +0100 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2023-11-28 15:52:49 +0000 |
commit | fa376883f0ce503e0346b1bb680a60df0dab52de (patch) | |
tree | 5b9df8147027e4b74d18f4082b702a9ad67cedd4 | |
parent | c5f023751f0001a120622c614b23188764553f71 (diff) |
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>
-rw-r--r-- | src/libs/qmljs/qmljsinterpreter.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 63e009607b..9448ef39b0 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -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)) { |