QQuickWindow: let 'clearFocusObject' clear all the way to the root
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>
Fri, 7 Nov 2014 10:33:14 +0000 (11:33 +0100)
committerRichard Moe Gustavsen <richard.gustavsen@digia.com>
Fri, 7 Nov 2014 13:00:42 +0000 (14:00 +0100)
The previous code was wrong, as it cleared focus from the active
focus item directly. By doing so we would only clear focus inside
the focus scope that surrounded the item, but leave the scope itself
with active focus (which would then be the focus object). The intended
result is rather to end up with the root as focus object.

Change-Id: I455a8939f8bc6c48765119b995aa781aee6d1e70
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
src/quick/items/qquickwindow.cpp

index 619e539..262e227 100644 (file)
@@ -893,8 +893,10 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
 
 void QQuickWindowPrivate::clearFocusObject()
 {
-    if (activeFocusItem)
-        activeFocusItem->setFocus(false, Qt::OtherFocusReason);
+    if (activeFocusItem == contentItem)
+        return;
+
+    clearFocusInScope(contentItem, QQuickItemPrivate::get(contentItem)->subFocusItem, Qt::OtherFocusReason);
 }
 
 void QQuickWindowPrivate::notifyFocusChangesRecur(QQuickItem **items, int remaining)