diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-05-27 13:28:26 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-05-27 14:01:52 (GMT) |
commit | 2c54f49584023633c5992579d23dc6819ec79c9e (patch) | |
tree | 9a0478fccf23b8de47f85a838a2fee04a8ec325f /tests | |
parent | ddf119a57001edd71eb6b84dffc7cda4a8ca2c0e (diff) | |
download | Qt-2c54f49584023633c5992579d23dc6819ec79c9e.zip Qt-2c54f49584023633c5992579d23dc6819ec79c9e.tar.gz Qt-2c54f49584023633c5992579d23dc6819ec79c9e.tar.bz2 |
Wrong QGraphicsItem::childrenBoundingRect() when applying effects.
Problem was that we used the children's raw bounding rect instead of
using their effective bounding rect when calculating the bounds.
Auto test included.
Task-number: QTBUG-10756
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 300afc3..5547b02 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -348,6 +348,7 @@ private slots: void childrenBoundingRect2(); void childrenBoundingRect3(); void childrenBoundingRect4(); + void childrenBoundingRect5(); void group(); void setGroup(); void setGroup2(); @@ -3369,6 +3370,34 @@ void tst_QGraphicsItem::childrenBoundingRect4() QCOMPARE(rect2->childrenBoundingRect(), rect3->boundingRect()); } +void tst_QGraphicsItem::childrenBoundingRect5() +{ + QGraphicsScene scene; + + QGraphicsRectItem *parent = scene.addRect(QRectF(0, 0, 100, 100)); + QGraphicsRectItem *child = scene.addRect(QRectF(0, 0, 100, 100)); + child->setParentItem(parent); + + QGraphicsView view(&scene); + view.show(); + + QTest::qWaitForWindowShown(&view); + + // Try to mess up the cached bounding rect. + QRectF expectedChildrenBoundingRect = parent->boundingRect(); + QCOMPARE(parent->childrenBoundingRect(), expectedChildrenBoundingRect); + + // Apply some effects. + QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect; + dropShadow->setOffset(25, 25); + child->setGraphicsEffect(dropShadow); + parent->setGraphicsEffect(new QGraphicsOpacityEffect); + + QVERIFY(parent->childrenBoundingRect() != expectedChildrenBoundingRect); + expectedChildrenBoundingRect |= dropShadow->boundingRect(); + QCOMPARE(parent->childrenBoundingRect(), expectedChildrenBoundingRect); +} + void tst_QGraphicsItem::group() { QGraphicsScene scene; |