From 49bc01b2cb3063144f420e2fd572b626f2849da8 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Thu, 11 Jan 2024 17:58:56 +0100 Subject: [PATCH] Android: Bail early in showInputPanel() when focusWindow is not native QAndroidInputContext::showInputPanel() assumes that any window with focus must be a native window, but sometimes the focus window will be an offscreen window, like in the case of using OpenXR where there is no native window to be focused. In that case the 2D input method overlay doesn't even make sense, since there is no window space to even map back to. This patch prevents crashes when trying to focus on text in Android VR/XR applications. Change-Id: I16ac1a07f0a86ec9786f09a2f416387c1885bde0 Reviewed-by: Assam Boudjelthia Reviewed-by: Laszlo Agocs --- src/plugins/platforms/android/qandroidinputcontext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 68a1ba0d07d..f6404fb00a4 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -884,6 +884,9 @@ void QAndroidInputContext::showInputPanel() if (query.isNull()) return; + if (!qGuiApp->focusWindow()->handle()) + return; // not a real window, probably VR/XR + disconnect(m_updateCursorPosConnection); m_updateCursorPosConnection = {};