summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-15 16:04:23 (GMT)
committerBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-15 16:06:26 (GMT)
commit862236dc7cdff27305c4a3ade9c802eafce03c80 (patch)
tree03aaa9bd6fb30f551999d9a3c1f39f069f04660e /tests/auto
parent31bed31d6d058a17d74de05a1653256decdfc735 (diff)
downloadQt-862236dc7cdff27305c4a3ade9c802eafce03c80.zip
Qt-862236dc7cdff27305c4a3ade9c802eafce03c80.tar.gz
Qt-862236dc7cdff27305c4a3ade9c802eafce03c80.tar.bz2
QGraphicsItems not painted after QGraphicsScene::clear().
The problem was that we didn't regenerate the bsp when adding items after calling QGraphicsScene::clear. Reviewed-by: alexis
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index 3ce5b16..7a00e60 100644
--- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -66,6 +66,7 @@ private slots:
void movingItems();
void connectedToSceneRectChanged();
void items();
+ void clear();
private:
void common_data();
@@ -267,5 +268,38 @@ void tst_QGraphicsSceneIndex::items()
QCOMPARE(scene.items().size(), 3);
}
+void tst_QGraphicsSceneIndex::clear()
+{
+ class MyItem : public QGraphicsItem
+ {
+ public:
+ MyItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent), numPaints(0) {}
+ int numPaints;
+ protected:
+ QRectF boundingRect() const { return QRectF(0, 0, 10, 10); }
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ { ++numPaints; }
+ };
+
+ QGraphicsScene scene;
+ scene.setSceneRect(0, 0, 100, 100);
+ scene.addItem(new MyItem);
+
+ QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(250);
+ scene.clear();
+
+ // Make sure the index is re-generated after QGraphicsScene::clear();
+ // otherwise no items will be painted.
+ MyItem *item = new MyItem;
+ scene.addItem(item);
+ qApp->processEvents();
+ QCOMPARE(item->numPaints, 1);
+}
+
QTEST_MAIN(tst_QGraphicsSceneIndex)
#include "tst_qgraphicssceneindex.moc"