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.

Change-Id: I0e01da42e96eb579d260b9158f005ad3215d0c26
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit f21c4500a6d4787d679d13e859b34d6c6a7a8c0e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2022-12-20 12:02:46 +01:00 committed by Qt Cherry-pick Bot
parent 9929a83183
commit 10772b6f7b

View File

@ -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();