summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicssceneindex
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-01 17:30:46 +0200
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-01 17:42:44 +0200
commit2b9294a2b47c4a193ef83be60a07a3e61b8531b4 (patch)
treed7f81c4ec5abc221462ee8bdafa09c24ce8e7359 /tests/auto/qgraphicssceneindex
parentf4a95e6d6e4c046ac4857cbd54f9488d3b67ce5a (diff)
Fixes broken BSP lookup in QGraphicsSceneBspTreeIndex.
The chip demo was unbelievable slow, so I investigated and found out the bsp always returned almost all items in the tree (40 000 in this particular case). It did so because the tree was initialized with an empty sceneRect. The sceneRect was empty due to a lacking signal-slot connection, resulting in QGraphicsSceneBspTreeIndex::updateSceneRect never being invoked. Auto-test included.
Diffstat (limited to 'tests/auto/qgraphicssceneindex')
-rw-r--r--tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index ac21e201a8..9d0675d7a7 100644
--- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -64,6 +64,7 @@ private slots:
void overlappedItems();
void movingItems_data();
void movingItems();
+ void connectedToSceneRectChanged();
private:
void common_data();
@@ -214,6 +215,18 @@ void tst_QGraphicsSceneIndex::movingItems()
QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 11);
}
+void tst_QGraphicsSceneIndex::connectedToSceneRectChanged()
+{
+
+ class MyScene : public QGraphicsScene
+ { public: using QGraphicsScene::receivers; };
+
+ MyScene scene; // Uses QGraphicsSceneBspTreeIndex by default.
+ QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(const QRectF&))), 1);
+
+ scene.setItemIndexMethod(QGraphicsScene::NoIndex); // QGraphicsSceneLinearIndex
+ QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(const QRectF&))), 1);
+}
QTEST_MAIN(tst_QGraphicsSceneIndex)
#include "tst_qgraphicssceneindex.moc"