diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-03-30 17:36:40 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-02 08:03:23 +0200 |
commit | 9cddbbff9da88ba9c889ae1f306e837c3a66377e (patch) | |
tree | 450af1f4a12bf82eb475a113e1cd419ceffea216 /tests/auto/quick/qquickitem/tst_qquickitem.cpp | |
parent | 5bb0180645ce55c28eb8b923bee61c74de3b9c0e (diff) |
Fix crash when changing the grandparent of an item with focus.
When an item was reparented it's sub focus item was cleared and those
of it's children were cleared along with those in the tree the item was
removed from. Since we now rely on the focus state of an unparented
tree to be correct we need to restore the sub focus items of the
unparented tree.
Change-Id: I236c512751b99092c7e9a39194f4680304bfacc5
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickitem/tst_qquickitem.cpp')
-rw-r--r-- | tests/auto/quick/qquickitem/tst_qquickitem.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index afb5c01542..a1377694e4 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -141,6 +141,7 @@ private slots: void multipleFocusClears(); void focusSubItemInNonFocusScope(); void parentItemWithFocus(); + void reparentFocusedItem(); void constructor(); void setParentItem(); @@ -822,6 +823,34 @@ void tst_qquickitem::parentItemWithFocus() } } +void tst_qquickitem::reparentFocusedItem() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem parent(canvas.rootItem()); + QQuickItem child(&parent); + QQuickItem sibling(&parent); + QQuickItem grandchild(&child); + + FocusState focusState; + focusState << &parent << &child << &sibling << &grandchild; + FVERIFY(); + + grandchild.setFocus(true); + focusState[&parent].set(false, false); + focusState[&child].set(false, false); + focusState[&sibling].set(false, false); + focusState[&grandchild].set(true, true); + focusState.active(&grandchild); + FVERIFY(); + + // Parenting the item to another item within the same focus scope shouldn't change it's focus. + child.setParentItem(&sibling); + FVERIFY(); +} + void tst_qquickitem::constructor() { QQuickItem *root = new QQuickItem; |