summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-04-03 14:39:58 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-06 11:49:55 (GMT)
commit3dc62362f3380fa653bc1225ce06e5e4cefa745a (patch)
treea1cc6ad6d4e5c9f4b7aca1b8a2353c26d43e4b15
parent32767aa5699937a3737b9515f4f82acc04ccdfcd (diff)
downloadQt-3dc62362f3380fa653bc1225ce06e5e4cefa745a.zip
Qt-3dc62362f3380fa653bc1225ce06e5e4cefa745a.tar.gz
Qt-3dc62362f3380fa653bc1225ce06e5e4cefa745a.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.
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index f0d360a..c4297df 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;