wasm: remove event listeners

Remove event listeners on shutdown. For emscripten
event callbacks this can be done by passing nullptr
as the callback, for DOM event listeners use the
“removeEventListener” API.

Change-Id: I5a32a6a8feb906082db5ef3d0a0cd7ecb3b54292
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Morten Sørvig 2021-05-26 12:25:09 +02:00 committed by Morten Johan Sørvig
parent 0ca0f3e7fe
commit 586027f7fd

View File

@ -142,7 +142,7 @@ QWasmIntegration::QWasmIntegration()
integration->resizeAllScreens();
return 0;
};
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, 1, onWindowResize);
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, EM_TRUE, onWindowResize);
// install visualViewport resize handler which picks up size and scale change on mobile.
emscripten::val visualViewport = emscripten::val::global("window")["visualViewport"];
@ -154,6 +154,14 @@ QWasmIntegration::QWasmIntegration()
QWasmIntegration::~QWasmIntegration()
{
// Remove event listenes
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, EM_TRUE, nullptr);
emscripten::val visualViewport = emscripten::val::global("window")["visualViewport"];
if (!visualViewport.isUndefined()) {
visualViewport.call<void>("removeEventListener", val("resize"),
val::module_property("qtResizeAllScreens"));
}
delete m_fontDb;
delete m_desktopServices;