diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-05-26 13:53:06 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-05-26 14:50:19 (GMT) |
commit | 11a8c52498e8dc74fdfef48e953055338c8f18d7 (patch) | |
tree | cb66294f39a2660bfac73b5dbccd21b85dfb65bc /tests/auto | |
parent | cf1e3150247d6694e8c00b924627c66e798f2382 (diff) | |
download | Qt-11a8c52498e8dc74fdfef48e953055338c8f18d7.zip Qt-11a8c52498e8dc74fdfef48e953055338c8f18d7.tar.gz Qt-11a8c52498e8dc74fdfef48e953055338c8f18d7.tar.bz2 |
Redraw issues when removing a fully transparent QGraphicsItem from the scene.
This only happened with fully transparent ancestors (item's
effectiveOpacity() == 0.0). Problem was that we didn't take into
account the ancestors' opacity when removing an item from the scene.
More specifically: The calculated effective opacity for the item was
zero and we ignored update requests. We have to ignore the opacity if
any of the ancestors' ignoreOpacity bit is 1, which means the opacity
is set to 0 and the update request has not yet been processed.
Auto test included.
Task-number: QTBUG-10778
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index a155222..67a41ca 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -275,6 +275,7 @@ private slots: void polishItems2(); void isActive(); void siblingIndexAlwaysValid(); + void removeFullyTransparentItem(); // task specific tests below me void task139710_bspTreeCrash(); @@ -4333,6 +4334,48 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() } +void tst_QGraphicsScene::removeFullyTransparentItem() +{ + QGraphicsScene scene; + + QGraphicsItem *parent = scene.addRect(0, 0, 100, 100); + parent->setFlag(QGraphicsItem::ItemHasNoContents); + + QGraphicsItem *child = scene.addRect(0, 0, 100, 100); + child->setParentItem(parent); + + CustomView view; + view.setScene(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + // NB! The parent has the ItemHasNoContents flag set, which means + // the parent itself doesn't generate any update requests, only the + // child can possibly trigger an update. Also note that the child + // is removed before processing events. + view.repaints = 0; + parent->setOpacity(0); + QVERIFY(qFuzzyIsNull(child->effectiveOpacity())); + scene.removeItem(child); + QVERIFY(!scene.items().contains(child)); + QTRY_VERIFY(view.repaints > 0); + + // Re-add child. There's nothing new to display (child is still + // effectively hidden), so it shouldn't trigger an update. + view.repaints = 0; + child->setParentItem(parent); + QVERIFY(scene.items().contains(child)); + QVERIFY(qFuzzyIsNull(child->effectiveOpacity())); + QApplication::processEvents(); + QCOMPARE(view.repaints, 0); + + // Nothing is visible on the screen, removing child item shouldn't trigger an update. + scene.removeItem(child); + QApplication::processEvents(); + QCOMPARE(view.repaints, 0); + delete child; +} + void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() { QGraphicsScene scene; |