summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-04 13:35:53 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:33:29 (GMT)
commit2e8a236108f5b78c4d61a254f4097ccf271f90cb (patch)
treeca79ca7577d3b1452c472933922ff3a4f210b139
parent5127105efd8f76721d7d9acf9681fd18e73760d8 (diff)
downloadQt-2e8a236108f5b78c4d61a254f4097ccf271f90cb.zip
Qt-2e8a236108f5b78c4d61a254f4097ccf271f90cb.tar.gz
Qt-2e8a236108f5b78c4d61a254f4097ccf271f90cb.tar.bz2
Ensure we can find and draw items whose size is (0x0).
This removes a microoptimization we did to avoid processing items whose size was (0x0). Turns out an autotest started failing if we did this - we have to find and draw such items because they are commonly used to draw points (e.g., plot graphs). Reviewed-by: bnilsen
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp61
1 files changed, 27 insertions, 34 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index a137b06..bb26bb6 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -297,13 +297,9 @@ static inline bool QRectF_intersects(const QRectF &s, const QRectF &r)
static inline void _q_adjustRect(QRectF *rect)
{
Q_ASSERT(rect);
- bool nullWidth = !rect->width();
- bool nullHeight = !rect->height();
- if (nullWidth && nullHeight)
- return;
- if (nullWidth)
+ if (!rect->width())
rect->adjust(-0.00001, 0, 0.00001, 0);
- else if (nullHeight)
+ if (!rect->height())
rect->adjust(0, -0.00001, 0, 0.00001);
}
@@ -1413,33 +1409,26 @@ void QGraphicsScenePrivate::recursive_items_helper(QGraphicsItem *item, QRectF r
if (item) {
item->d_ptr->combineTransformFromParent(&transform, &viewTransform);
+ // ### This does not take the clip into account.
QRectF brect = item->boundingRect();
- if (!brect.size().isNull()) {
- // ### This does not take the clip into account.
- _q_adjustRect(&brect);
-
- keep = true;
- if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
- keep = rect.contains(transform.mapRect(brect));
- else
- keep = rect.intersects(transform.mapRect(brect));
-
- if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
- QPainterPath rectPath;
- rectPath.addRect(rect);
- keep = item->collidesWithPath(transform.inverted().map(rectPath));
- }
+ _q_adjustRect(&brect);
+
+ keep = true;
+ if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
+ keep = rect.contains(transform.mapRect(brect));
+ else
+ keep = rect.intersects(transform.mapRect(brect));
+
+ if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
+ QPainterPath rectPath;
+ rectPath.addRect(rect);
+ keep = item->collidesWithPath(transform.inverted().map(rectPath));
}
}
bool childClip = (item && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape));
bool dontProcessItem = !item || !keep;
bool dontProcessChildren = item && dontProcessItem && childClip;
- childClip &= !dontProcessChildren & !children.isEmpty();
-
- // Clip.
- if (childClip)
- rect &= transform.map(item->shape()).controlPointRect();
// Find and sort children.
QList<QGraphicsItem *> &children = item ? item->d_ptr->children : const_cast<QGraphicsScenePrivate *>(this)->topLevelItems;
@@ -1453,6 +1442,12 @@ void QGraphicsScenePrivate::recursive_items_helper(QGraphicsItem *item, QRectF r
}
}
+ childClip &= !dontProcessChildren & !children.isEmpty();
+
+ // Clip.
+ if (childClip)
+ rect &= transform.map(item->shape()).controlPointRect();
+
// Process children behind
int i = 0;
if (!dontProcessChildren) {
@@ -5142,14 +5137,12 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
}
QRectF brect = item->boundingRect();
- if (!brect.size().isNull()) {
- // ### This does not take the clip into account.
- _q_adjustRect(&brect);
- viewBoundingRect = transformTmp.mapRect(brect).toRect().adjusted(-1, -1, 1, 1);
- item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
- if (exposedRegion)
- viewBoundingRect &= exposedRegion->boundingRect();
- }
+ // ### This does not take the clip into account.
+ _q_adjustRect(&brect);
+ viewBoundingRect = transformTmp.mapRect(brect).toRect().adjusted(-1, -1, 1, 1);
+ item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
+ if (exposedRegion)
+ viewBoundingRect &= exposedRegion->boundingRect();
}
// Find and sort children.