From cfc606d91eb1a7ec7f9be8643b6fca4865bd59cf Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 20 Jun 2024 09:53:20 +0200 Subject: [PATCH] QmlJS: Skip QtQuick3D for implicit imports The way we resolve implicit imports creates random issues. QtQuick3D.MaterialEditor implicitly imports QtQuick3D. If QtQuick3D.MaterialEditor is scanned before QtQuick3D the types of QtQuick3D are added to QtQuick3D.MaterialEditor and when later QtQuick3D is scanned no type is added to QtQuick3D because of the cache in ::createObjectsForImport. The result is that QtQuick3D does not contain its types and prototypes cannot be resolved. This does happen roughly 50% of the time and is the reported issue. In case QtQuick3D is scanned, first things work, but no "extra types" types are added to QtQuick3D.MaterialEditor. To keep the patch minimal we simply skip this specific case. QtQuick importing QtQml implicitly is not touched. Task-number: QDS-11069 Change-Id: I74088b12a2e737a8a7467068c10a78c4be2a7bda Reviewed-by: Miikka Heikkinen (cherry picked from commit f92ea99107172a2adc067e5d4756d36f73c93965) Reviewed-by: Tim Jenssen --- src/libs/qmljs/qmljslink.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 97c00e1c8d9..40198809be7 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -512,6 +512,16 @@ bool LinkPrivate::importLibrary(const Document::Ptr &doc, // commands in qmldir files, and is pending removal in Qt 6. for (const auto &toImport : libraryInfo.imports()) { QString importName = toImport.module; + + // These implicit imports do not work reliable, since each type + // is only added to one import/module. If a type is added here, + // it is not added to the actual module, because of caching. + // + // In case of QtQuick3D.MaterialEditor this leads to a reproducible issue. + // As a workaround we simply skip all implicit imports for QtQuick3D. + if (importName == "QtQuick3D") + continue; + ComponentVersion vNow = toImport.version; /* There was a period in which no version == auto * Required for QtQuick imports less than 2.15