summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-15 10:23:08 +0200
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-15 10:38:59 +0200
commit7a0f9ae94ca7a47dc285431d31f6839c07870194 (patch)
treeac46d83f38015a708237574db351db2c2af9380f /tests/auto/qgraphicsscene
parentb33ebce3de3efd98a45c8ca0a349f78aac09c875 (diff)
BT: Fix a regression to 4.4 in Graphics View's handling of child clippers
Regression caused by optimizations in QGraphicsItem and QGraphicsScene. The changes in QGraphicsItem fix bugs in QGraphicsItem::mapToParent functions, which did the translation before applying the transformation, instead of the other way (transform, then translate). This bug caused almost all mapToParent and mapRectToParent functions to behave wrongly. Unfortunately the new helper functions in QGraphicsScene for discovering items made use of these functions, which introduced a regression. Fixing these functions also fixes item discovery. The other part of this change fixes a regression caused by c1909321, which luckily happened after 4.5.0 and never saw the light of day. The fix is to also invalidate the cached clip path even if there is no scene, which is necessary if you build your scene graph outside the scene, and finish off by adding the root item to the scene. Task-number: 250680 Reviewed-by: Alexis
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 91ed851005..354d81ae4d 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -245,6 +245,7 @@ private slots:
void task139782_containsItemBoundingRect();
void task176178_itemIndexMethodBreaksSceneRect();
void task160653_selectionChanged();
+ void task250680_childClip();
};
void tst_QGraphicsScene::initTestCase()
@@ -3384,6 +3385,31 @@ void tst_QGraphicsScene::task160653_selectionChanged()
QCOMPARE(spy.count(), 1);
}
+void tst_QGraphicsScene::task250680_childClip()
+{
+ QGraphicsRectItem *clipper = new QGraphicsRectItem;
+ clipper->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ clipper->setPen(QPen(Qt::green));
+ clipper->setRect(200, 200, 640, 480);
+
+ QGraphicsRectItem *rect = new QGraphicsRectItem(clipper);
+ rect->setPen(QPen(Qt::red));
+ rect->setBrush(QBrush(QColor(255, 0, 0, 75)));
+ rect->setPos(320, 240);
+ rect->setRect(-25, -25, 50, 50);
+
+ QGraphicsScene scene;
+ scene.addItem(clipper);
+
+ QPainterPath path;
+ path.addRect(-25, -25, 50, 50);
+ QCOMPARE(rect->clipPath(), path);
+
+ QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2);
+ rect->rotate(45);
+ QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2);
+}
+
void tst_QGraphicsScene::sorting_data()
{
QTest::addColumn<bool>("cache");