diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-08 11:09:14 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-09 07:36:05 (GMT) |
commit | 0095e40b2efc0c43c0d908bb5b9828619bc087e7 (patch) | |
tree | 95850288ca3b4171e400c57b5d703b17fafbeb67 /tests/auto | |
parent | 9cafd6bcf6f91c027904c998a0dd536feac8d4e0 (diff) | |
download | Qt-0095e40b2efc0c43c0d908bb5b9828619bc087e7.zip Qt-0095e40b2efc0c43c0d908bb5b9828619bc087e7.tar.gz Qt-0095e40b2efc0c43c0d908bb5b9828619bc087e7.tar.bz2 |
QGraphicsItem discard updates when it shouldn't.
Once a _q_processDirtyItems call is queued, it means we at least have
one item that is marked as dirty and we must reset it when the
_q_processDirtyItems slot is called. The problem however, was that
we didn't reset the item's dirty state if a full scene update occurred
in between, i.e. item->update(); scene.update();
We don't have to calculate the item's dirty rect if a full scene update
occurs in between, but we still have to reset its state.
Auto-test included.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 427ecf3..5b297f6 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -219,6 +219,7 @@ private slots: void updateCachedItemAfterMove(); void deviceTransform_data(); void deviceTransform(); + void update(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -6427,5 +6428,32 @@ void tst_QGraphicsItem::deviceTransform() QCOMPARE(rect3->deviceTransform(deviceX).map(QPointF(50, 50)), mapResult3); } +void tst_QGraphicsItem::update() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(100); + + EventTester *item = new EventTester; + scene.addItem(item); + QTest::qWait(100); // Make sure all pending updates are processed. + item->repaints = 0; + + item->update(); // Item marked as dirty + scene.update(); // Entire scene marked as dirty + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + + // Make sure the dirty state from the previous update is reset so that + // the item don't think it is already dirty and discards this update. + item->update(); + qApp->processEvents(); + QCOMPARE(item->repaints, 2); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |