diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-10-22 12:49:40 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-10-23 08:34:46 (GMT) |
commit | cc4d3fbc317bc9044c3ce23569f0225b29af4fd5 (patch) | |
tree | c76592219af2ddfc1d2a049d03ee98f8807a3639 /tests | |
parent | a95883e90fadeddd2f49da6765fb2d79f7ce77bd (diff) | |
download | Qt-cc4d3fbc317bc9044c3ce23569f0225b29af4fd5.zip Qt-cc4d3fbc317bc9044c3ce23569f0225b29af4fd5.tar.gz Qt-cc4d3fbc317bc9044c3ce23569f0225b29af4fd5.tar.bz2 |
QGraphicsLineItem leave traces when moving around (reg. against 4.5)
The problem was that QGraphicsLineItem's bounding rect is an empty rect
(either width is 0 or height is 0), and when updating the item's old
occupied area, we explicitly checked whether the rect was empty() or
not. In case of being empty (rect.isEmpty()) we did nothing, which was
the root of the problem.
We can safely remove the rect.isEmpty() check without any significant
loss of performance since the common case is that the rect is non-empty.
And in the case of being empty, we'll bail out from
QGraphicsViewPrivate::updateRect's highly optimized rect intersection.
Auto test included.
Task: QTBUG-4877
Reviewed-by: alexis
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index dcad8e1..4fae911 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -372,6 +372,7 @@ private slots: void itemUsesExtendedStyleOption(); void itemSendsGeometryChanges(); void moveItem(); + void moveLineItem(); void sorting_data(); void sorting(); void itemHasNoContents(); @@ -7438,6 +7439,39 @@ void tst_QGraphicsItem::moveItem() COMPARE_REGIONS(view.paintedRegion, expectedParentRegion); } +void tst_QGraphicsItem::moveLineItem() +{ + QGraphicsScene scene; + scene.setSceneRect(0, 0, 200, 200); + QGraphicsLineItem *item = new QGraphicsLineItem(0, 0, 100, 0); + item->setPos(50, 50); + scene.addItem(item); + + MyGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(200); + view.reset(); + + const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) + .mapRect(item->boundingRect()).toRect(); + QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); // antialiasing + + // Make sure the calculated region is correct. + item->update(); + QTest::qWait(10); + QCOMPARE(view.paintedRegion, expectedRegion); + view.reset(); + + // Old position: (50, 50) + item->setPos(50, 100); + expectedRegion += expectedRegion.translated(0, 50); + QTest::qWait(10); + QCOMPARE(view.paintedRegion, expectedRegion); +} + void tst_QGraphicsItem::sorting_data() { QTest::addColumn<int>("index"); |