summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsitem
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-05 15:29:23 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-06 12:03:59 (GMT)
commit4909d2661d47a28c0ee932d9dfb5b8c47a376044 (patch)
tree9596a9a18c15ecc33c548b7a5a7e30599831ab7a /tests/auto/qgraphicsitem
parentbefbee33497290b6e5448b1249e4ace83fcda27b (diff)
downloadQt-4909d2661d47a28c0ee932d9dfb5b8c47a376044.zip
Qt-4909d2661d47a28c0ee932d9dfb5b8c47a376044.tar.gz
Qt-4909d2661d47a28c0ee932d9dfb5b8c47a376044.tar.bz2
Wrong caching of QGraphicsItem::childrenBoundingRect.
We cannot cache the bounding rect on the fly for children, because the bounding rect is mapped to the callee's local coordinate system. Auto-test included.
Diffstat (limited to 'tests/auto/qgraphicsitem')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index ceb033e..d07c6fd 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -215,6 +215,7 @@ private slots:
void childrenBoundingRect();
void childrenBoundingRectTransformed();
void childrenBoundingRect2();
+ void childrenBoundingRect3();
void group();
void setGroup();
void nestedGroups();
@@ -3052,6 +3053,39 @@ void tst_QGraphicsItem::childrenBoundingRect2()
QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100));
}
+void tst_QGraphicsItem::childrenBoundingRect3()
+{
+ QGraphicsScene scene;
+
+ QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 100, 100));
+ QGraphicsRectItem *rect2 = scene.addRect(QRectF(0, 0, 100, 100));
+ QGraphicsRectItem *rect3 = scene.addRect(QRectF(0, 0, 100, 100));
+ QGraphicsRectItem *rect4 = scene.addRect(QRectF(0, 0, 100, 100));
+ QGraphicsRectItem *rect5 = scene.addRect(QRectF(0, 0, 100, 100));
+ rect2->setParentItem(rect);
+ rect3->setParentItem(rect2);
+ rect4->setParentItem(rect3);
+ rect5->setParentItem(rect4);
+
+ rect2->setTransform(QTransform().translate(50, 50).rotate(45));
+ rect2->setPos(25, 25);
+ rect3->setTransform(QTransform().translate(50, 50).rotate(45));
+ rect3->setPos(25, 25);
+ rect4->setTransform(QTransform().translate(50, 50).rotate(45));
+ rect4->setPos(25, 25);
+ rect5->setTransform(QTransform().translate(50, 50).rotate(45));
+ rect5->setPos(25, 25);
+
+ // Try to mess up the cached bounding rect.
+ (void)rect2->childrenBoundingRect();
+
+ QRectF subTreeRect = rect->childrenBoundingRect();
+ QCOMPARE(subTreeRect.left(), qreal(-206.0660171779821));
+ QCOMPARE(subTreeRect.top(), qreal(75.0));
+ QCOMPARE(subTreeRect.width(), qreal(351.7766952966369));
+ QCOMPARE(subTreeRect.height(), qreal(251.7766952966369));
+}
+
void tst_QGraphicsItem::group()
{
QGraphicsScene scene;