From d6eb00f537fc8924f7844c98426fbd0c8882621b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 11 Dec 2025 16:27:47 +0100 Subject: QtQml: Do not load resolved CompilationUnits from other engines If the type loader doesn't have a QQmlDataBlob in its cache, then this engine hasn't ever loaded and resolved the respective compilation unit. We can't skip the type resolution then because the current engine may have different URL interceptors, import paths, plugin paths etc than the one that previously loaded the CU. This leads to different type resolutions. This should not re-open QTBUG-134398 since now the base compilation units are not shared between engines anymore, despite still being stored in the type registry. Amends commit 27c2c989a3d10557da15de3d45bb5bd7b96d14e8. Amends commit 6468df7657f6af4de8727363c7f7d97b680b1867. Pick-to: 6.11 6.10 6.8 Fixes: QTBUG-142658 Change-Id: I10139492c38b4a943ecca41928ec96097cd8bfbe Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4engine.cpp | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) (limited to 'src/qml/jsruntime/qv4engine.cpp') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 59d2d6c7fa..5df48560e3 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -2165,37 +2166,8 @@ ExecutionEngine::Module ExecutionEngine::moduleForUrl( return *existingModule; } - // Compilation Unit present in QQmlMetaTypeData - if (auto cu = QQmlMetaType::obtainCompilationUnit(resolved)) - return executableCompilationUnit(std::move(cu)); - - // Compilation Unit readily loadable from .qmlc file or binary - QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError; - const DiskCacheOptions options = diskCacheOptions(); - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = (options & DiskCache::Aot) - ? QQmlMetaType::findCachedCompilationUnit( - resolved, - (options & DiskCache::AotByteCode) - ? QQmlMetaType::AcceptUntyped - : QQmlMetaType::RequireFullyTyped, - &cacheError) - : nullptr) { - const auto cu = executableCompilationUnit( - QQml::makeRefPointer( - cachedUnit->qmlData, cachedUnit->aotCompiledFunctions, - resolved.fileName(), resolved.toString())); - const auto data = cu->unitData(); - for (uint i = 0, end = data->moduleRequestTableSize; i < end; ++i) { - const auto dependency = moduleForUrl(cu->urlAt(data->moduleRequestTable()[i]), cu.data()); - QQmlRefPointer scriptData( - new QQmlScriptData, QQmlRefPointer::Adopt); - scriptData->url = dependency->finalUrl(); - scriptData->urlString = dependency->finalUrlString(); - scriptData->m_precompiledScript = dependency->baseCompilationUnit(); - cu->baseCompilationUnit()->dependentScripts.append(std::move(scriptData)); - } - return cu; - } + if (const auto blob = m_typeLoader->getScript(resolved, QQmlTypeLoader::Synchronous)) + return executableCompilationUnit(blob->scriptData()->compilationUnit()); // Unavailable return Module(); -- cgit v1.2.3