summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-10 08:37:29 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-10 08:54:32 (GMT)
commit28f31572b95a28e14f7ed4cebb907cfe1e257177 (patch)
treefcb9aeda2e5ee0abc81b1983e3f31d19a0c6d17e /tests
parentbdb6d461f4889e38296c859446283c0f9397dbdd (diff)
downloadQt-28f31572b95a28e14f7ed4cebb907cfe1e257177.zip
Qt-28f31572b95a28e14f7ed4cebb907cfe1e257177.tar.gz
Qt-28f31572b95a28e14f7ed4cebb907cfe1e257177.tar.bz2
Painting artifacts when moving an item with partial updates.
Found during manual testing (dndrobotinproxy). The problem was that the paintedViewBoundingRect was set to an empty rect because the partial update area didn't intersect with the viewport. The item itself was partially inside the viewport. Then, when the item was moved, its old area was not repainted due to this empty paintedViewBoundingRect. Auto-test included.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index d689293..2dbd5f1 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -6580,6 +6580,7 @@ public:
void tst_QGraphicsItem::update()
{
QGraphicsScene scene;
+ scene.setSceneRect(-100, -100, 200, 200);
MyGraphicsView view(&scene);
view.show();
@@ -6636,6 +6637,52 @@ void tst_QGraphicsItem::update()
QCOMPARE(view.repaints, 1);
// The entire item's bounding rect (adjusted for antialiasing) should have been painted.
QCOMPARE(view.paintedRegion, expectedRegion);
+
+ // Make sure item is repainted when shown (after being hidden).
+ view.reset();
+ item->repaints = 0;
+ item->show();
+ qApp->processEvents();
+ QCOMPARE(item->repaints, 1);
+ QCOMPARE(view.repaints, 1);
+ // The entire item's bounding rect (adjusted for antialiasing) should have been painted.
+ QCOMPARE(view.paintedRegion, expectedRegion);
+
+ item->repaints = 0;
+ item->hide();
+ qApp->processEvents();
+ view.reset();
+ const QPointF originalPos = item->pos();
+ item->setPos(5000, 5000);
+ qApp->processEvents();
+ QCOMPARE(item->repaints, 0);
+ QCOMPARE(view.repaints, 0);
+ qApp->processEvents();
+
+ item->setPos(originalPos);
+ qApp->processEvents();
+ QCOMPARE(item->repaints, 0);
+ QCOMPARE(view.repaints, 0);
+ item->show();
+ qApp->processEvents();
+ QCOMPARE(item->repaints, 1);
+ QCOMPARE(view.repaints, 1);
+ // The entire item's bounding rect (adjusted for antialiasing) should have been painted.
+ QCOMPARE(view.paintedRegion, expectedRegion);
+
+ QGraphicsViewPrivate *viewPrivate = static_cast<QGraphicsViewPrivate *>(qt_widget_private(&view));
+ item->setPos(originalPos + QPoint(50, 50));
+ viewPrivate->updateAll();
+ QVERIFY(viewPrivate->fullUpdatePending);
+ QTest::qWait(50);
+ item->repaints = 0;
+ view.reset();
+ item->setPos(originalPos);
+ QTest::qWait(50);
+ qApp->processEvents();
+ QCOMPARE(item->repaints, 1);
+ QCOMPARE(view.repaints, 1);
+ QCOMPARE(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
}
void tst_QGraphicsItem::setTransformProperties_data()