iOS: Detect mismatched calls to IM::update() before IM::setFocusObject()
The focus object should be updated, resulting in a reset(), before any manual calls to update() from client code. To be on the safe side we try to detect when this assertion fails and manually fix the situation, so that we show/hide the keyboard correctly based on the new focus item. Change-Id: I15a614cc9553b0a26b0dc7f7beefb56a84645861 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
ff5ce39e21
commit
80bbaf6fad
@ -650,11 +650,21 @@ void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
|
||||
*/
|
||||
void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
|
||||
{
|
||||
qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject();
|
||||
|
||||
// Changes to the focus object should always result in a call to setFocusObject(),
|
||||
// triggering a reset() which will update all the properties based on the new
|
||||
// focus object. We try to detect code paths that fail this assertion and smooth
|
||||
// over the situation by doing a manual update of the focus object.
|
||||
if (qApp->focusObject() != m_imeState.focusObject && updatedProperties != Qt::ImQueryAll) {
|
||||
qWarning() << "stale focus object" << m_imeState.focusObject << ", doing manual update";
|
||||
setFocusObject(qApp->focusObject());
|
||||
return;
|
||||
}
|
||||
|
||||
// Mask for properties that we are interested in and see if any of them changed
|
||||
updatedProperties &= (Qt::ImEnabled | Qt::ImHints | Qt::ImQueryInput | Qt::ImEnterKeyType | Qt::ImPlatformData);
|
||||
|
||||
qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject();
|
||||
|
||||
// Perform update first, so we can trust the value of inputMethodAccepted()
|
||||
Qt::InputMethodQueries changedProperties = m_imeState.update(updatedProperties);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user