summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2023-11-28 18:12:12 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2023-12-12 09:00:56 +0000
commitbf39bd8e06e9d66bfb9f01e83c743420e812b630 (patch)
treea2348d04d2525306c4c53e381775b01ab40978e9 /src/plugins/platforms/wasm
parent06c724881c4227acf308e54ebd3db8235bb6b740 (diff)
wasm: fix qtloader.js preRun usage
Emscripten documents that preRun should be an array of functions, but also accepts setting it to a single function. qtloader.js was accidentally using this feature, which works as long as qtloader is the single user, but breaks if other code expects an array. A typical error in this case is: "Module.preRun.push is not a function" Fix this by creating and maintaining preRun as an array. Pick-to: 6.6 6.7 Change-Id: Ie1382695f3f25839cb971ab4adc81984fc8c53ca Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm')
-rw-r--r--src/plugins/platforms/wasm/qtloader.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/platforms/wasm/qtloader.js b/src/plugins/platforms/wasm/qtloader.js
index 1b76d4ecc1..c0bb3652cf 100644
--- a/src/plugins/platforms/wasm/qtloader.js
+++ b/src/plugins/platforms/wasm/qtloader.js
@@ -116,15 +116,13 @@ async function qtLoad(config)
}
}
- const originalPreRun = config.preRun;
- config.preRun = instance =>
- {
- originalPreRun?.();
-
+ const qtPreRun = (instance) => {
+ // Copy qt.environment to instance.ENV
throwIfEnvUsedButNotExported(instance, config);
for (const [name, value] of Object.entries(config.qt.environment ?? {}))
instance.ENV[name] = value;
+ // Copy self.preloadData to MEMFS
const makeDirs = (FS, filePath) => {
const parts = filePath.split("/");
let path = "/";
@@ -142,13 +140,16 @@ async function qtLoad(config)
}
}
}
-
throwIfFsUsedButNotExported(instance, config);
for ({destination, data} of self.preloadData) {
makeDirs(instance.FS, destination);
instance.FS.writeFile(destination, new Uint8Array(data));
}
- };
+ }
+
+ if (!config.preRun)
+ config.preRun = [];
+ config.preRun.push(qtPreRun);
config.onRuntimeInitialized = () => config.qt.onLoaded?.();