aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-08-25 11:42:23 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-09-02 15:33:31 +0200
commitb297e8fccf262bb0d870b39a960f0b80193dcaf5 (patch)
tree1f5bb9adf1e3fcbd4a8490c64995c064f3ce1f74 /src/qmlworkerscript
parent7c56dc7e980fc2b0814fb4aec1d5484d4cd3f286 (diff)
QML: Make modules imported with registerModule() available in QML
So far, you could only use them from pure JavaScript programs. Also, fix re-exporting parts of native modules. Fixes: QTBUG-105901 Change-Id: I170017083284e6457b1aa0c6e606fd26227edae3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlworkerscript')
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index 336c3d5edb..0aa9b936c8 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -230,10 +230,12 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
script->source = url;
if (fileName.endsWith(QLatin1String(".mjs"))) {
- auto moduleUnit = engine->loadModule(url);
- if (moduleUnit) {
- if (moduleUnit->instantiate(engine))
- moduleUnit->evaluate();
+ auto module = engine->loadModule(url);
+ if (module.compiled) {
+ if (module.compiled->instantiate(engine))
+ module.compiled->evaluate();
+ } else if (module.native) {
+ // Nothing to do. There is no global code in a native module.
} else {
engine->throwError(QStringLiteral("Could not load module file"));
}