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 <aleksandr.reviakin@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Morten Sørvig 2022-04-26 11:46:46 +02:00 committed by Morten Johan Sørvig
parent b8b3a8047f
commit e4cda635b1

View File

@ -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()