Treat parentless items as focus scopes
authorAlan Alpert <alan.alpert@nokia.com>
Fri, 2 Mar 2012 00:36:10 +0000 (10:36 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 2 Mar 2012 06:22:53 +0000 (07:22 +0100)
The root item of a tree is implicitly a focus scope simply because it is
the root of the tree. QQuickRootItem could gain the focus scope flag in
order to solve this for most cases, but there would still be a
possiblity of a crash for disconnected trees.

Change-Id: I6e04f11df4268fb3b96660d50707d70935a5dc5e
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/quick/items/qquickitem.cpp

index 04f4c1f..7ca683f 100644 (file)
@@ -2121,7 +2121,7 @@ QQuickItem *QQuickItemPrivate::InitializationState::getFocusScope(QQuickItem *it
 {
     if (!focusScope) {
         QQuickItem *fs = item->parentItem();
-        while (!fs->isFocusScope())
+        while (fs->parentItem() && !fs->isFocusScope())
             fs = fs->parentItem();
         focusScope = fs;
     }