From e4cda635b134ccc1b94b5c802beb1d94f3a54789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Tue, 26 Apr 2022 11:46:46 +0200 Subject: [PATCH] wasm: destroy compositor and screen in order The QWasmCompositor destructor deregisters event handlers, which means it needs to look up the the canvas element, which again means that this needs to happen before we clear the canvas from specialHTMLTargets. Also, calling destroy() is not needed since the QWasmCompositor destructor makes this call. Change-Id: I3004b94d0459c28642d3bd8bf9fe794c9b658477 Reviewed-by: Aleksandr Reviakin Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmscreen.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index ef1fb39f5b..357ee327fe 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -119,13 +119,16 @@ QWasmScreen::QWasmScreen(const emscripten::val &containerOrCanvas) QWasmScreen::~QWasmScreen() { - emscripten::val specialHtmlTargets = emscripten::val::module_property("specialHTMLTargets"); + // Delete the compositor before removing the screen from specialHTMLTargets, + // since its destructor needs to look up the target when deregistering + // event handlers. + m_compositor = nullptr; + emscripten::val specialHtmlTargets = emscripten::val::module_property("specialHTMLTargets"); std::string id = std::string("!qtcanvas_") + std::to_string(uint32_t(this)); specialHtmlTargets.set(id, emscripten::val::undefined()); m_canvas.set(m_canvasResizeObserverCallbackContextPropertyName, emscripten::val(intptr_t(0))); - destroy(); } void QWasmScreen::destroy()