summaryrefslogtreecommitdiffstats
path: root/tests/manual/wasm/qtloader_integration/main.cpp
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2023-07-05 14:46:13 +0200
committerMorten Sørvig <morten.sorvig@qt.io>2023-07-10 05:13:56 +0200
commita4d1c30a1b52e797cce504f90bcf20d7943dd1f9 (patch)
treebc693b85bb1db721a6d6ce3a4781cd642ba49497 /tests/manual/wasm/qtloader_integration/main.cpp
parent20d17b1a3b0e3a17a0ed1214cc21d84d79d3c829 (diff)
wasm: clarify qtloader onExit behavior
onExit is called whenever the application exits, i.e. when the app canvas should no longer be displayed and the loader/embedder code should take some action. Emscripten provides two callbacks which can be used here: - onExit, called when the app exits (but see EXIT_RUNTIME) - onAbort, called on abort errors. These map to the two cases Qt's onExit supports. onExit is not called when EXIT_RUNTIME is disabled, which means we don't need the special case for exit code 0. In addition call onExit on any exception. The second call to showUi() in html_shell.html is then not needed any more and we avoid duplicating the UI state handling in user code. Update the qtloader_integration test to handle changes in behavior (we no longer set the error text on exit). Use emscripten_force_exit() to simulate application exit - using this function makes Emscripten call onExit even when EXIT_RUNTIME is disabled. Pick-to: 6.6 Change-Id: I72b5463c1836e8d5054e594abbd304fbc67032b7 Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Diffstat (limited to 'tests/manual/wasm/qtloader_integration/main.cpp')
-rw-r--r--tests/manual/wasm/qtloader_integration/main.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/manual/wasm/qtloader_integration/main.cpp b/tests/manual/wasm/qtloader_integration/main.cpp
index b9bed0d49b0..ee032e9952d 100644
--- a/tests/manual/wasm/qtloader_integration/main.cpp
+++ b/tests/manual/wasm/qtloader_integration/main.cpp
@@ -71,7 +71,7 @@ void crash()
void exitApp()
{
- exit(ExitValueFromExitApp);
+ emscripten_force_exit(ExitValueFromExitApp);
}
void produceOutput()
@@ -135,7 +135,7 @@ int main(int argc, char **argv)
std::find(arguments.begin(), arguments.end(), QStringLiteral("--exit-immediately"))
!= arguments.end();
if (exitImmediately)
- return ExitValueImmediateReturn;
+ emscripten_force_exit(ExitValueImmediateReturn);
const bool crashImmediately =
std::find(arguments.begin(), arguments.end(), QStringLiteral("--crash-immediately"))