summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-02 11:33:40 +0200
committerAlexis Menard <alexis.menard@nokia.com>2009-10-02 11:40:09 +0200
commit0573653f830fada99311c88ab46e8f5a37854b90 (patch)
tree9790c50179e57922e457c757af798d2f1543611f /src/gui
parentf1b22116ad94472a6f24a376cf3709a272870478 (diff)
Fix a bug when clipsChildrenToShape is set back to false.
If you set the flag itemClipsChildrenToShape to true on a parent, an optimization was made in 4.5.0 to not add children of this parent in the index. But when you set the flag back to false all the sub-tree of the parent should be re-added to the index otherwise the index will never find all children. This code is not relevant for 4.6 since the index part of QGraphicsView has been refactored and handle this case with itemChange in QGraphicsSceneIndex. Reviewed-by:andreas
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp3
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 4f77aa8bc9..280c365f34 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1262,6 +1262,9 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
}
+ if (d_ptr->scene && oldFlags & ItemClipsChildrenToShape)
+ d_ptr->scene->d_func()->addToUnindexedItems(this);
+
if ((flags & ItemClipsToShape) != (oldFlags & ItemClipsToShape))
d_ptr->invalidateCachedClipPath();
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 0fded89884..5c3e9bda9a 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -448,6 +448,20 @@ void QGraphicsScenePrivate::addToIndex(QGraphicsItem *item)
/*!
\internal
*/
+void QGraphicsScenePrivate::addToUnindexedItems(QGraphicsItem *item)
+{
+ if (indexMethod == QGraphicsScene::BspTreeIndex) {
+ item->d_func()->index = -1;
+ unindexedItems << item;
+
+ for (int i = 0 ; i < item->d_ptr->children.size() ; ++i)
+ addToUnindexedItems(item->d_ptr->children.at(i));
+ }
+}
+
+/*!
+ \internal
+*/
void QGraphicsScenePrivate::removeFromIndex(QGraphicsItem *item)
{
if (indexMethod == QGraphicsScene::BspTreeIndex) {
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 3c72874470..62bcbfb58e 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -89,6 +89,7 @@ public:
QList<QGraphicsItem *> estimateItemsInRect(const QRectF &rect) const;
void addToIndex(QGraphicsItem *item);
void removeFromIndex(QGraphicsItem *item);
+ void addToUnindexedItems(QGraphicsItem *item);
void resetIndex();
QGraphicsSceneBspTree bspTree;