diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-04-20 09:03:24 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-04-20 10:39:40 (GMT) |
commit | f6d816ffe37ac74d29a7423683d4e046a3906b74 (patch) | |
tree | f5aaee3721706fb3d9b7b7e04ad600aed057cbe2 /tests/auto/qgraphicseffect | |
parent | dd478a4b829921c9dfeb23110177a30f32eca5af (diff) | |
download | Qt-f6d816ffe37ac74d29a7423683d4e046a3906b74.zip Qt-f6d816ffe37ac74d29a7423683d4e046a3906b74.tar.gz Qt-f6d816ffe37ac74d29a7423683d4e046a3906b74.tar.bz2 |
No repaint when resizing graphics item with an effect.
Problem was that the item's cache was not invalidated from
prepareGeometryChange(). We did invalidate the cache for all the
ancestors, but not for the item itself. To avoid looping through the
whole parent chain twice, we invalidate the item's cache before
walking the parent chain. It would be nice to centralize the cache
invalidating mechanism, but for now it's OK to solve it like this.
Auto test included.
Task-number: QTBUG-9551
Reviewed-by: samuel
Diffstat (limited to 'tests/auto/qgraphicseffect')
-rw-r--r-- | tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index dbd4a23..5dc0c9d 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -75,6 +75,7 @@ private slots: void inheritOpacity(); void dropShadowClipping(); void childrenVisibilityShouldInvalidateCache(); + void prepareGeometryChangeInvalidateCache(); }; void tst_QGraphicsEffect::initTestCase() @@ -647,6 +648,33 @@ void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache() QCOMPARE(parent.nbPaint, 3); } +void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache() +{ + MyGraphicsItem *item = new MyGraphicsItem; + item->resize(200, 200); + + QGraphicsScene scene; + scene.addItem(item); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(item->nbPaint, 1); + + item->nbPaint = 0; + item->setGraphicsEffect(new QGraphicsDropShadowEffect); + QTRY_COMPARE(item->nbPaint, 1); + + item->nbPaint = 0; + item->resize(300, 300); + QTRY_COMPARE(item->nbPaint, 1); + + item->nbPaint = 0; + item->setPos(item->pos() + QPointF(10, 10)); + QTest::qWait(50); + QCOMPARE(item->nbPaint, 0); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" |