Skip to content

Commit 83b6139

Browse files
author
Morten Sørvig
committed
wasm: use QWasmWindow::fromWindow()
Make it test for null QWindow and handle(), use it instead of C-style casting handle(). Change-Id: I7ffb1ef5d3d3c09c8ae44ec0141e93530a04abe6 Reviewed-by: Even Oscar Andersen <[email protected]> Reviewed-by: Piotr Wierciński <[email protected]>
1 parent bdc9665 commit 83b6139

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/plugins/platforms/wasm/qwasminputcontext.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ void QWasmInputContext::updateInputElement()
327327
m_inputElement.set("value", "");
328328

329329
m_inputElement.call<void>("blur");
330-
if (focusWindow && focusWindow->handle())
331-
((QWasmWindow *)(focusWindow->handle()))->focus();
330+
if (QWasmWindow *wasmwindow = QWasmWindow::fromWindow(focusWindow))
331+
wasmwindow->focus();
332332

333333
return;
334334
}

src/plugins/platforms/wasm/qwasmwindow.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ QSurfaceFormat QWasmWindow::format() const
211211
return window()->requestedFormat();
212212
}
213213

214-
QWasmWindow *QWasmWindow::fromWindow(QWindow *window)
214+
QWasmWindow *QWasmWindow::fromWindow(const QWindow *window)
215215
{
216+
if (!window ||!window->handle())
217+
return nullptr;
216218
return static_cast<QWasmWindow *>(window->handle());
217219
}
218220

src/plugins/platforms/wasm/qwasmwindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class QWasmWindow final : public QPlatformWindow,
4545
QWasmBackingStore *backingStore, WId nativeHandle);
4646
~QWasmWindow() final;
4747

48-
static QWasmWindow *fromWindow(QWindow *window);
48+
static QWasmWindow *fromWindow(const QWindow *window);
4949
QSurfaceFormat format() const override;
5050

5151
void registerEventHandlers();

0 commit comments

Comments
 (0)