diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-08-11 17:59:49 +0200 |
---|---|---|
committer | Shane Kearns <shane.kearns@sosco.com> | 2009-08-11 18:13:17 +0200 |
commit | 262d0348f7a38a22809662e296545d07d686afde (patch) | |
tree | 7aa47dfdebbb35c9664b8476034de73df3b0009f /tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | |
parent | c5e1630f0ca7062dd602d7e91f47362e5506f858 (diff) |
Fix autotest failure in qgraphicsitem.
When autofocused child is deleted, remove from ancestors to avoid double
deletion crash.
Check for null receiver when auto SIP is enabled in mouseReleaseEvent
Diffstat (limited to 'tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 558688f4e2..892e1823d8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -160,6 +160,7 @@ public slots: void init(); private slots: + void explicitDeleteAutoFocusProxy(); void construction(); void constructionWithParent(); void destruction(); @@ -7516,5 +7517,28 @@ void tst_QGraphicsItem::reverseCreateAutoFocusProxy() QVERIFY(text2->hasFocus()); } +void tst_QGraphicsItem::explicitDeleteAutoFocusProxy() +{ + QGraphicsTextItem *text = new QGraphicsTextItem; + text->setTextInteractionFlags(Qt::TextEditorInteraction); + text->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); + + QGraphicsTextItem *text2 = new QGraphicsTextItem; + text2->setTextInteractionFlags(Qt::TextEditorInteraction); + text2->setFocus(); + QVERIFY(!text2->hasFocus()); + QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); + text2->setParentItem(text); + QCOMPARE(text->focusProxy(), (QGraphicsItem *)text2); + QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); + + QGraphicsScene scene; + scene.addItem(text); + QVERIFY(text2->hasFocus()); + + delete text2; + QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |