Wasm: fix QtVirtualKeyboard crash

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 <morten.sorvig@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
(cherry picked from commit 41cb01dc595c8de374ce58ae43afbb69db70c379)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit f01a0e9ed90cd970d5b089648424ab4af1aed594)
This commit is contained in:
Lorn Potter 2024-05-07 09:06:44 +10:00 committed by Qt Cherry-pick Bot
parent a428c69335
commit b5fbe0923c

View File

@ -128,9 +128,8 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport,
});
emscripten::val keyFocusWindow;
if (QWasmIntegration::get()->inputContext()) {
QWasmInputContext *wasmContext =
static_cast<QWasmInputContext *>(QWasmIntegration::get()->inputContext());
if (QWasmInputContext *wasmContext =
qobject_cast<QWasmInputContext *>(QWasmIntegration::get()->inputContext())) {
// if there is an touchscreen input context,
// use that window for key input
keyFocusWindow = wasmContext->m_inputElement;