summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2021-05-19 11:43:11 +0200
committerMorten Sørvig <morten.sorvig@qt.io>2021-06-23 08:57:27 +0200
commit2e12c2caf5e32a3deda4c01afd96b362748b7c3e (patch)
tree4bd2a9c380e4aa8b98cbd5fe9b2dc48c0e85bec9 /src/plugins/platforms
parent53eb44906c73997335e702d3eef40dec8f6b9cf7 (diff)
wasm: do not quit() on beforeunload()
This is the wrong event: exiting the app here it is not compatible with the back/forward cache for instance. See the the MDN docs for the “Window: unload” event. Instead, make the Qt default be that we assume the app process will live “forever” until the browser terminates it, much like modern process handling on e.g. iOS. We may want to come back to app lifecycle handling at a later point. This might require changes to application code: implementing main() in such that it supports clean shutdowns and auditing showdown code to make sure it is web-compatible. Change-Id: I0f32026a3af76c9cc79e3aab31e8aaed7b8f8023 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp14
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.h1
2 files changed, 0 insertions, 15 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index 2f2524737d..470deb6d70 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -62,11 +62,6 @@
using namespace emscripten;
QT_BEGIN_NAMESPACE
-static void browserBeforeUnload(emscripten::val)
-{
- QWasmIntegration::QWasmBrowserExit();
-}
-
static void addCanvasElement(emscripten::val canvas)
{
QWasmIntegration::get()->addScreen(canvas);
@@ -95,7 +90,6 @@ static void resizeAllScreens(emscripten::val event)
EMSCRIPTEN_BINDINGS(qtQWasmIntegraton)
{
- function("qtBrowserBeforeUnload", &browserBeforeUnload);
function("qtAddCanvasElement", &addCanvasElement);
function("qtRemoveCanvasElement", &removeCanvasElement);
function("qtResizeCanvasElement", &resizeCanvasElement);
@@ -127,8 +121,6 @@ QWasmIntegration::QWasmIntegration()
addScreen(canvas);
}
- emscripten::val::global("window").set("onbeforeunload", val::module_property("qtBrowserBeforeUnload"));
-
// install browser window resize handler
auto onWindowResize = [](int eventType, const EmscriptenUiEvent *e, void *userData) -> int {
Q_UNUSED(eventType);
@@ -172,12 +164,6 @@ QWasmIntegration::~QWasmIntegration()
s_instance = nullptr;
}
-void QWasmIntegration::QWasmBrowserExit()
-{
- QCoreApplication *app = QCoreApplication::instance();
- app->quit();
-}
-
bool QWasmIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h
index f527053489..16c48e1ea1 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.h
+++ b/src/plugins/platforms/wasm/qwasmintegration.h
@@ -82,7 +82,6 @@ public:
QWasmClipboard *getWasmClipboard() { return m_clipboard; }
static QWasmIntegration *get() { return s_instance; }
- static void QWasmBrowserExit();
void addScreen(const emscripten::val &canvas);
void removeScreen(const emscripten::val &canvas);