diff options
author | Bjoern Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-04-03 14:39:58 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-04-15 10:23:54 (GMT) |
commit | 45e2f2f949b8655b6de9b3a875dd8509d1c5369e (patch) | |
tree | 5933aa61daffd7e06fe48e760841625fda9d0115 | |
parent | d715f695b96e408c5858ab708c18dca16b69d91e (diff) | |
download | Qt-45e2f2f949b8655b6de9b3a875dd8509d1c5369e.zip Qt-45e2f2f949b8655b6de9b3a875dd8509d1c5369e.tar.gz Qt-45e2f2f949b8655b6de9b3a875dd8509d1c5369e.tar.bz2 |
Fixes: We have to adjust the item's bounding rect.
RevBy: Andreas
AutoTest: Still pass
Details: QRectF::intersects does not work with flat rectangles, so
we cannot intersect the bounding rect without adjusting it
first.
(cherry picked from commit 3dc62362f3380fa653bc1225ce06e5e4cefa745a)
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 140bc71..24aae43 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -790,6 +790,19 @@ QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const Q return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect(); } +// QRectF::intersects() returns false always if either the source or target +// rectangle's width or height are 0. This works around that problem. +static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item) +{ + Q_ASSERT(item); + QRectF boundingRect(item->boundingRect()); + if (!boundingRect.width()) + boundingRect.adjust(-0.00001, 0, 0.00001, 0); + if (!boundingRect.height()) + boundingRect.adjust(0, -0.00001, 0, 0.00001); + return boundingRect; +} + /*! \internal */ @@ -802,7 +815,7 @@ void QGraphicsViewPrivate::itemUpdated(QGraphicsItem *item, const QRectF &rect) QRectF updateRect = rect; if ((item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) || item->d_ptr->children.isEmpty()) { - updateRect &= item->boundingRect(); + updateRect &= adjustedItemBoundingRect(item); if (updateRect.isEmpty()) return; } @@ -814,7 +827,8 @@ void QGraphicsViewPrivate::itemUpdated(QGraphicsItem *item, const QRectF &rect) while ((parent = parent->d_ptr->parent)) { if (parent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) { // Map update rect to the current parent and itersect with its bounding rect. - updateRect = clipItem->itemTransform(parent).mapRect(updateRect) & parent->boundingRect(); + updateRect = clipItem->itemTransform(parent).mapRect(updateRect) + & adjustedItemBoundingRect(parent); if (updateRect.isEmpty()) return; clipItem = parent; |