aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript/qquickworkerscript.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-12-04 11:53:32 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-12-06 17:39:19 +0100
commitdc60c305a20d518012d4f034c4fa2a7395ebf31f (patch)
tree1677d6e9328f2cb58339bf2fcdbbcb7b2e577138 /src/qmlworkerscript/qquickworkerscript.cpp
parent70d00b55329c36ac046172707d141cdd9b7dda9e (diff)
QtQml: Model native modules as compilation units
QQmlTypeLoader::injectedScript() was unsafe and impossible to fix because it had to query the engine from the type loader thread in order to find out whether to load a script from an actual file. By removing the whole special-casing of native modules, we can make the script loading thread safe. A native module is now also a compilation unit, with a regular QV4::Module as value. This means we can remove a lot of code that deals with the native modules in the engine. The downside is that native modules are now a lot larger than before. However, given that they don't appear in any examples and hardly any bugs have been filed about native modules since their introduction, we can assume that they are not a very popular feature. The reduction in complexity and the removal of the native modules map in the engine is expected to outweigh the extra memory overhead for native modules. Task-number: QTBUG-131721 Pick-to: 6.8 Change-Id: Ia7388d7ba8d71637559a791d874257fba4646330 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlworkerscript/qquickworkerscript.cpp')
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index 20061c9df7..dc19b3a119 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -253,12 +253,9 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
script->source = url;
if (fileName.endsWith(QLatin1String(".mjs"))) {
- auto module = engine->loadModule(url);
- if (module.compiled) {
- if (module.compiled->instantiate())
- module.compiled->evaluate();
- } else if (module.native) {
- // Nothing to do. There is no global code in a native module.
+ if (auto module = engine->loadModule(url)) {
+ if (module->instantiate())
+ module->evaluate();
} else {
engine->throwError(QStringLiteral("Could not load module file"));
}