From 41cb01dc595c8de374ce58ae43afbb69db70c379 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 Pick-to: 6.7 6.7.1 Change-Id: Iedac1890d13b348ef12690947779347e3c2f8476 Reviewed-by: Morten Johan Sørvig Reviewed-by: Piotr Wierciński --- 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 0513f46e5bb..99e9bb22f1b 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;