diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-01-20 14:11:58 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-01-29 16:25:08 (GMT) |
commit | 08c649e6a81ab13d0c7db6aa1b480ed149e3f770 (patch) | |
tree | 8a130b0fcc01890392563af2135eaa84f274c87b /tests | |
parent | 3db33d41ad48953ec7c8d74db24d17fc3685895f (diff) | |
download | Qt-08c649e6a81ab13d0c7db6aa1b480ed149e3f770.zip Qt-08c649e6a81ab13d0c7db6aa1b480ed149e3f770.tar.gz Qt-08c649e6a81ab13d0c7db6aa1b480ed149e3f770.tar.bz2 |
Avoids missing opacity updates by not propagating the ignoreOpacity flag
When doing a full update of a parent item, by setting one of these flags,
QGraphicsItem::ItemIgnoresTransformations | ItemClipsChildrenToShape |
ItemIsSelectable, the child items that were transparent would not be
shown when setting their respective opacity to 1.0
We just need to set the ignoreOpacity flag when setting opacity to 0.0.
This avoids propagating this flag to the child items when it's not
needed.
Task-number: QT-2653
Reviewed-by: bnilsen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index a515481..dd8d555 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -434,6 +434,7 @@ private slots: void QTBUG_4233_updateCachedWithSceneRect(); void QTBUG_5418_textItemSetDefaultColor(); void QTBUG_6738_missingUpdateWithSetParent(); + void QT_2653_fullUpdateDiscardingOpacityUpdate(); private: QList<QGraphicsItem *> paintedItems; @@ -9919,5 +9920,44 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() QTRY_VERIFY(view.repaints == 1); } +void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate() +{ + QGraphicsScene scene(0, 0, 200, 200); + MyGraphicsView view(&scene); + + EventTester *parentGreen = new EventTester(); + parentGreen->setGeometry(QRectF(20, 20, 100, 100)); + parentGreen->brush = Qt::green; + + EventTester *childYellow = new EventTester(parentGreen); + childYellow->setGeometry(QRectF(10, 10, 50, 50)); + childYellow->brush = Qt::yellow; + + scene.addItem(parentGreen); + + childYellow->setOpacity(0.0); + parentGreen->setOpacity(0.0); + + // set any of the flags below to trigger a fullUpdate to reproduce the bug: + // ItemIgnoresTransformations, ItemClipsChildrenToShape, ItemIsSelectable + parentGreen->setFlag(QGraphicsItem::ItemIgnoresTransformations); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.reset(); + + parentGreen->setOpacity(1.0); + + QTRY_COMPARE(view.repaints, 1); + + view.reset(); + childYellow->repaints = 0; + + childYellow->setOpacity(1.0); + + QTRY_COMPARE(view.repaints, 1); + QTRY_COMPARE(childYellow->repaints, 1); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |