summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-06-23 11:01:15 +0200
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-06-23 12:41:30 +0200
commita8a0c956f747cd09ca04cfe8b33d09a8476c6453 (patch)
tree5eaefe921a5f45f290d5dcb701eb71f142f68f25 /src/corelib
parentaacf96f414651c516b11518d9a921d9853d09e69 (diff)
Regression against 4.4 in QRectF::operator|.
In 4.4 QRectF handled flat rectangles in the same fashion as QRect does, but that changed with Lars' and Jo's optmizations done in the falcon branch. The difference is that the optimized version only checks whether the width or height is 0, whereas in 4.4 both had to be 0 (isNull()) before we bailed out. This regression also introduced a regression in QGraphicsItem::childrenBoundingRect(). Auto-test included. Task-number: 254995 Reviewed-by: Lars
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qrect.cpp62
-rw-r--r--src/corelib/tools/qrect.h2
2 files changed, 29 insertions, 35 deletions
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index 2082794c2a..b4fe07009a 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -2154,48 +2154,42 @@ bool QRectF::contains(const QRectF &r) const
QRectF QRectF::operator|(const QRectF &r) const
{
- qreal l1 = xp;
- qreal r1 = xp;
- if (w < 0)
- l1 += w;
- else
- r1 += w;
- if (l1 == r1) // null rect
+ if (isNull())
return r;
+ if (r.isNull())
+ return *this;
- qreal l2 = r.xp;
- qreal r2 = r.xp;
- if (r.w < 0)
- l2 += r.w;
+ qreal left = xp;
+ qreal right = xp;
+ if (w < 0)
+ left += w;
else
- r2 += r.w;
- if (l2 == r2) // null rect
- return *this;
+ right += w;
- qreal t1 = yp;
- qreal b1 = yp;
+ if (r.w < 0) {
+ left = qMin(left, r.xp + r.w);
+ right = qMax(right, r.xp);
+ } else {
+ left = qMin(left, r.xp);
+ right = qMax(right, r.xp + r.w);
+ }
+
+ qreal top = yp;
+ qreal bottom = yp;
if (h < 0)
- t1 += h;
+ top += h;
else
- b1 += h;
- if (t1 == b1) // null rect
- return r;
+ bottom += h;
- qreal t2 = r.yp;
- qreal b2 = r.yp;
- if (r.h < 0)
- t2 += r.h;
- else
- b2 += r.h;
- if (t2 == b2) // null rect
- return *this;
+ if (r.h < 0) {
+ top = qMin(top, r.yp + r.h);
+ bottom = qMax(bottom, r.yp);
+ } else {
+ top = qMin(top, r.yp);
+ bottom = qMax(bottom, r.yp + r.h);
+ }
- QRectF tmp;
- tmp.xp = qMin(l1, l2);
- tmp.yp = qMin(t1, t2);
- tmp.w = qMax(r1, r2) - tmp.xp;
- tmp.h = qMax(b1, b2) - tmp.yp;
- return tmp;
+ return QRectF(left, top, right - left, bottom - top);
}
/*!
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 0740fe5cd6..efdc24da40 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -653,7 +653,7 @@ inline QRectF::QRectF(const QRect &r)
}
inline bool QRectF::isNull() const
-{ return qIsNull(w) && qIsNull(h); }
+{ return w == 0. && h == 0.; }
inline bool QRectF::isEmpty() const
{ return w <= 0. || h <= 0.; }