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>
This commit is contained in:
parent
53eb44906c
commit
2e12c2caf5
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user