From b5fbe0923cfc566036b83c3d968f225b26117efc Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 7 May 2024 09:06:44 +1000 Subject: [PATCH] Wasm: fix QtVirtualKeyboard crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not try to access non the existent input element when there is no touchscreen, as we do not use it in that instance. Fixes: QTBUG-125120 Change-Id: Iedac1890d13b348ef12690947779347e3c2f8476 Reviewed-by: Morten Johan Sørvig Reviewed-by: Piotr Wierciński (cherry picked from commit 41cb01dc595c8de374ce58ae43afbb69db70c379) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit f01a0e9ed90cd970d5b089648424ab4af1aed594) --- src/plugins/platforms/wasm/qwasmwindow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index cda1faac8d9..19c73255d4d 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -128,9 +128,8 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport, }); emscripten::val keyFocusWindow; - if (QWasmIntegration::get()->inputContext()) { - QWasmInputContext *wasmContext = - static_cast(QWasmIntegration::get()->inputContext()); + if (QWasmInputContext *wasmContext = + qobject_cast(QWasmIntegration::get()->inputContext())) { // if there is an touchscreen input context, // use that window for key input keyFocusWindow = wasmContext->m_inputElement;