From cb023cbc2ab494eead21b721040a0a90db0f755c Mon Sep 17 00:00:00 2001
From: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Date: Fri, 7 Nov 2014 11:33:14 +0100
Subject: [PATCH] QQuickWindow: let 'clearFocusObject' clear all the way to the
 root
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 619e539204..262e227b16 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -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)
-- 
GitLab