diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-09 15:10:58 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-09 15:18:07 (GMT) |
commit | ebb1162f54a29baeccb71d1e283146892629518f (patch) | |
tree | 509880629128bf0f1d62f75fb40d87dc1fbcee8a /tests | |
parent | 948038f077ea413ab7aa7634d1c9987ec7ab50f6 (diff) | |
download | Qt-ebb1162f54a29baeccb71d1e283146892629518f.zip Qt-ebb1162f54a29baeccb71d1e283146892629518f.tar.gz Qt-ebb1162f54a29baeccb71d1e283146892629518f.tar.bz2 |
Fix crash/bug in QGraphicsItem's subFocus handling.
Removes dangling subFocusItem pointers when changing focus after
reparenting. This change also includes a mini-optimization when adding
focusable items to an inactive scene.
Reviewed-by: brad
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 65837ae..5e8f4c4 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -7620,6 +7620,7 @@ void tst_QGraphicsItem::subFocus() QCOMPARE(text2->focusItem(), (QGraphicsItem *)text2); text2->setParentItem(text); QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); + QCOMPARE(text2->focusItem(), (QGraphicsItem *)text2); QVERIFY(!text->hasFocus()); QVERIFY(text2->hasFocus()); @@ -7644,6 +7645,12 @@ void tst_QGraphicsItem::subFocus() QGraphicsRectItem *rect3 = new QGraphicsRectItem(rect2); rect3->setFlag(QGraphicsItem::ItemIsFocusable); + text->setData(0, "text"); + text2->setData(0, "text2"); + rect->setData(0, "rect"); + rect2->setData(0, "rect2"); + rect3->setData(0, "rect3"); + rect3->setFocus(); QVERIFY(!rect3->hasFocus()); QCOMPARE(rect->focusItem(), (QGraphicsItem *)rect3); @@ -7651,6 +7658,10 @@ void tst_QGraphicsItem::subFocus() QCOMPARE(rect3->focusItem(), (QGraphicsItem *)rect3); rect->setParentItem(text2); QCOMPARE(text->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(text2->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect2->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect3->focusItem(), (QGraphicsItem *)rect3); QVERIFY(!rect->hasFocus()); QVERIFY(!rect2->hasFocus()); QVERIFY(rect3->hasFocus()); |