wasm: Fix nullptr access in QWasmScreen::allwindows

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 <morten.sorvig@qt.io>
bb10
Even Oscar Andersen 2024-05-06 09:07:28 +02:00
parent 1a4470a8ef
commit 1530c475e9
1 changed files with 8 additions and 4 deletions

View File

@ -361,10 +361,14 @@ QList<QWasmWindow *> QWasmScreen::allWindows()
{
QList<QWasmWindow *> windows;
for (auto *child : childStack()) {
QWindowList list = child->window()->findChildren<QWindow *>(Qt::FindChildrenRecursively);
std::transform(
list.begin(), list.end(), std::back_inserter(windows),
[](const QWindow *window) { return static_cast<QWasmWindow *>(window->handle()); });
const QWindowList list = child->window()->findChildren<QWindow *>(Qt::FindChildrenRecursively);
for (auto child : list) {
auto handle = child->handle();
if (handle) {
auto wnd = static_cast<QWasmWindow *>(handle);
windows.push_back(wnd);
}
}
windows.push_back(child);
}
return windows;