From 1530c475e98d2dfdc2f6fc55ecc4d8707544191c Mon Sep 17 00:00:00 2001 From: Even Oscar Andersen Date: Mon, 6 May 2024 09:07:28 +0200 Subject: wasm: Fix nullptr access in QWasmScreen::allwindows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the QWindow::handle() has not been created yet we will add a zero page pointer to the allwindows list. One possible symptom is that emscripten::val complains in context2d() that it is accessed by the wrong thread. what happens is that the this pointer points to the first page. Seen in the documentviewer example Change-Id: I2b08176ebdd7c35d5105194f7fd9f4f6d45b77e5 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmscreen.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index ddf8140c48..0490b2bfe0 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -361,10 +361,14 @@ QList QWasmScreen::allWindows() { QList windows; for (auto *child : childStack()) { - QWindowList list = child->window()->findChildren(Qt::FindChildrenRecursively); - std::transform( - list.begin(), list.end(), std::back_inserter(windows), - [](const QWindow *window) { return static_cast(window->handle()); }); + const QWindowList list = child->window()->findChildren(Qt::FindChildrenRecursively); + for (auto child : list) { + auto handle = child->handle(); + if (handle) { + auto wnd = static_cast(handle); + windows.push_back(wnd); + } + } windows.push_back(child); } return windows; -- cgit v1.2.3