summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2023-10-25 12:14:36 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2023-12-20 00:44:27 +0000
commitac4619a36a54a2168ea5d7a2c7d059781564098c (patch)
tree1134c5dd5028053fc509e2f8150db707077c4940 /src/plugins/platforms/wasm
parentf413229184e91e8dbe7b7cb1e74cbce39e21dde4 (diff)
wasm: call onExit once and only once on exit
We listen to the onExit and on onAbort Emscripten events, and also handle exit by exception. Make sure we call onExit only once on exit, regardless of the order and number of Emscripten events. Pick-to: 6.7 Change-Id: I4833a1056fad0a2706bd6c0f0fce98fb052fe8c8 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.js38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/plugins/platforms/wasm/qtloader.js b/src/plugins/platforms/wasm/qtloader.js
index 1789ad70e3..176d0ce4d7 100644
--- a/src/plugins/platforms/wasm/qtloader.js
+++ b/src/plugins/platforms/wasm/qtloader.js
@@ -169,25 +169,32 @@ async function qtLoad(config)
return originalLocatedFilename;
}
+ let onExitCalled = false;
const originalOnExit = config.onExit;
config.onExit = code => {
originalOnExit?.();
- config.qt.onExit?.({
- code,
- crashed: false
- });
+
+ if (!onExitCalled) {
+ onExitCalled = true;
+ config.qt.onExit?.({
+ code,
+ crashed: false
+ });
+ }
}
const originalOnAbort = config.onAbort;
config.onAbort = text =>
{
originalOnAbort?.();
-
- aborted = true;
- config.qt.onExit?.({
- text,
- crashed: true
- });
+
+ if (!onExitCalled) {
+ onExitCalled = true;
+ config.qt.onExit?.({
+ text,
+ crashed: true
+ });
+ }
};
const fetchPreloadFiles = async () => {
@@ -213,10 +220,13 @@ async function qtLoad(config)
instance = await Promise.race(
[circuitBreaker, config.qt.entryFunction(config)]);
} catch (e) {
- config.qt.onExit?.({
- text: e.message,
- crashed: true
- });
+ if (!onExitCalled) {
+ onExitCalled = true;
+ config.qt.onExit?.({
+ text: e.message,
+ crashed: true
+ });
+ }
throw e;
}