From f21c4500a6d4787d679d13e859b34d6c6a7a8c0e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 20 Dec 2022 12:02:46 +0100 Subject: [PATCH] Android input context: don't connect to non-existing signal Not all focus objects have a cursorPositionChanged signal, so don't connect unless there is one. The code should perhaps not show the software keyboard at all unless the focus object responds to the input method query with cursor positions, but that's for a different patch. Pick-to: 6.5 Change-Id: I0e01da42e96eb579d260b9158f005ad3215d0c26 Reviewed-by: Assam Boudjelthia Reviewed-by: Qt CI Bot --- src/plugins/platforms/android/qandroidinputcontext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 679c142289..4c111be829 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -896,9 +896,11 @@ void QAndroidInputContext::showInputPanel() return; disconnect(m_updateCursorPosConnection); + m_updateCursorPosConnection = {}; + if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition())); - else + else if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged()") >= 0) m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition())); QRect rect = screenInputItemRectangle();