diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-01 15:30:46 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-01 15:42:44 (GMT) |
commit | 2b9294a2b47c4a193ef83be60a07a3e61b8531b4 (patch) | |
tree | d7f81c4ec5abc221462ee8bdafa09c24ce8e7359 /src/gui/graphicsview/qgraphicssceneindex.cpp | |
parent | f4a95e6d6e4c046ac4857cbd54f9488d3b67ce5a (diff) | |
download | Qt-2b9294a2b47c4a193ef83be60a07a3e61b8531b4.zip Qt-2b9294a2b47c4a193ef83be60a07a3e61b8531b4.tar.gz Qt-2b9294a2b47c4a193ef83be60a07a3e61b8531b4.tar.bz2 |
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 'src/gui/graphicsview/qgraphicssceneindex.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicssceneindex.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/gui/graphicsview/qgraphicssceneindex.cpp index 2f2f05e..b317e8e 100644 --- a/src/gui/graphicsview/qgraphicssceneindex.cpp +++ b/src/gui/graphicsview/qgraphicssceneindex.cpp @@ -303,24 +303,31 @@ void QGraphicsSceneIndexPrivate::recursive_items_helper(QGraphicsItem *item, QRe } } +void QGraphicsSceneIndexPrivate::init() +{ + if (!scene) + return; + + QObject::connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), + q_func(), SLOT(updateSceneRect(const QRectF&))); +} + /*! Constructs an abstract scene index for a given \a scene. */ QGraphicsSceneIndex::QGraphicsSceneIndex(QGraphicsScene *scene) : QObject(*new QGraphicsSceneIndexPrivate(scene), scene) { - if (scene) { - connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), - this, SLOT(updateSceneRect(const QRectF&))); - } + d_func()->init(); } /*! \internal */ -QGraphicsSceneIndex::QGraphicsSceneIndex(QObjectPrivate &dd, QGraphicsScene *scene) +QGraphicsSceneIndex::QGraphicsSceneIndex(QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene) : QObject(dd, scene) { + d_func()->init(); } /*! |