diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-08-26 11:48:48 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-08-26 12:42:05 +0200 |
commit | 4b944cb61fb3ceee2f1b743823e4a83b686bafd6 (patch) | |
tree | 856154bc1e90be7cdd41fdadcfe1994315e03f9d /src | |
parent | 4d080635872fbb77a2adfb736d3f108b62cc058a (diff) |
Fix loading of ES modules when using CONFIG += qtquickcompiler
Added the missing lookup for cached .mjs files in
ExecutionEngine::compileModule. This allows using .mjs files in
WorkerScript {} elements in conjunction with the Qt Quick Compiler and
also fixes the use when using QJSEngine::importModule.
[ChangeLog][QtQml] Fix loading of EcmaScript modules when using the Qt
Quick Compiler.
Fixes: QTBUG-77761
Change-Id: I58130b0468f4920b2f6c49b98a2f51d5ae3a0491
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index b6000dbcca..f9747207db 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1743,6 +1743,13 @@ ReturnedValue ExecutionEngine::global() QQmlRefPointer<CompiledData::CompilationUnit> ExecutionEngine::compileModule(const QUrl &url) { + QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError; + if (const QV4::CompiledData::Unit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url, &cacheError)) { + QQmlRefPointer<QV4::CompiledData::CompilationUnit> jsUnit; + jsUnit.adopt(new QV4::CompiledData::CompilationUnit(cachedUnit, url.fileName(), url.toString())); + return jsUnit; + } + QFile f(QQmlFile::urlToLocalFileOrQrc(url)); if (!f.open(QIODevice::ReadOnly)) { throwError(QStringLiteral("Could not open module %1 for reading").arg(url.toString())); |