summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-01-03 17:46:55 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-01-11 11:36:34 +0000
commit80bbaf6fad7376a94bc460eb6e98031bb5266ce1 (patch)
treec306ada5d5154654e116c524ee65576e2a493bec /src/plugins/platforms/ios
parentff5ce39e2195392289935040de4a301b1ccb1200 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 9608b6eae7..237077400b 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -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);