diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-09-16 10:38:51 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-09-16 16:25:57 (GMT) |
commit | e76564e8a3b305f4fe69135bebb409e357f29f57 (patch) | |
tree | 56c2557f519b5936d6357fac57f6a486925f146c /src/gui/graphicsview/qgraphicsitem.cpp | |
parent | 3d7ef01963f2e15b7fd8fd23ffe22198ced00c87 (diff) | |
download | Qt-e76564e8a3b305f4fe69135bebb409e357f29f57.zip Qt-e76564e8a3b305f4fe69135bebb409e357f29f57.tar.gz Qt-e76564e8a3b305f4fe69135bebb409e357f29f57.tar.bz2 |
Wrong bounding rect returned by QGraphicsEffect::boundingRect().
Regression after: f5c5e20a
Problem was that the cached bounding rect was never invalidated. We can
also remove the cached bounding rect in QGraphicsEffectSource because
QGraphicsItem::childrenBoundingRect now clips by default. This basically
means partially reverting above commit and invalidate whenever
ItemClipsChildrenToShape flag changes.
Auto test included.
Task-number: Discovered while investigating QT-3633
Reviewed-by: samuel
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 2600d06..364fdbb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1272,7 +1272,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q Returns the bounding rect of this item's children (excluding itself). */ -void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, bool doClip) +void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect) { Q_Q(QGraphicsItem); @@ -1302,7 +1302,7 @@ void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rec } } - if (doClip && (flags & QGraphicsItem::ItemClipsChildrenToShape)){ + if (flags & QGraphicsItem::ItemClipsChildrenToShape){ if (x) *rect &= x->mapRect(q->boundingRect()); else @@ -1870,6 +1870,10 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) // Item children clipping changes. Propagate the ancestor flag to // all children. d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); + // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape, + // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes. + d_ptr->dirtyChildrenBoundingRect = 1; + d_ptr->markParentDirty(true); } if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) { @@ -11168,14 +11172,8 @@ QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem syste } QRectF rect = item->boundingRect(); - if (!item->d_ptr->children.isEmpty()) { - if (dirtyChildrenBoundingRect) { - childrenBoundingRect = QRectF(); - item->d_ptr->childrenBoundingRectHelper(0, &childrenBoundingRect, true); - dirtyChildrenBoundingRect = false; - } - rect |= childrenBoundingRect; - } + if (!item->d_ptr->children.isEmpty()) + rect |= item->childrenBoundingRect(); if (deviceCoordinates) { Q_ASSERT(info->painter); |