aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-12-11 16:27:47 +0100
committerUlf Hermann <ulf.hermann@qt.io>2025-12-15 09:39:13 +0100
commitd6eb00f537fc8924f7844c98426fbd0c8882621b (patch)
treef0b3da13aaaf8d502b1bf3fdd5c504b15badfc4b /src/qml/jsruntime/qv4engine.cpp
parent8ba31901cbeb626da9e77504d056810f0b1654ec (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp34
1 files changed, 3 insertions, 31 deletions
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 <private/qqmljsdiagnosticmessage_p.h>
#include <private/qqmllist_p.h>
#include <private/qqmllistwrapper_p.h>
+#include <private/qqmlscriptblob_p.h>
#include <private/qqmlscriptdata_p.h>
#include <private/qqmltypeloader_p.h>
#include <private/qqmltypewrapper_p.h>
@@ -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<QV4::CompiledData::CompilationUnit>(
- 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<QQmlScriptData> scriptData(
- new QQmlScriptData, QQmlRefPointer<QQmlScriptData>::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();