From bcb4dbebe2f6216842ce443bfc6d126943020a35 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 25 Sep 2010 19:23:12 +0200 Subject: Fix QPainter::clipBoundingRect() for QRectF clip. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clipBoundingRect() wasn't handling QPainterClipInfo::RectFClip properly, mistaking it for PathClip. Reviewed-by: Samuel Rødal --- src/gui/painting/qpainter.cpp | 2 ++ tests/auto/qpainter/tst_qpainter.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 8f54a2e..35a74c9 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2737,6 +2737,8 @@ QRectF QPainter::clipBoundingRect() const if (info.clipType == QPainterClipInfo::RectClip) r = info.rect; + else if (info.clipType == QPainterClipInfo::RectFClip) + r = info.rectf; else if (info.clipType == QPainterClipInfo::RegionClip) r = info.region.boundingRect(); else diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 9b8444c..ae97285 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -4543,6 +4543,14 @@ void tst_QPainter::clipBoundingRect() QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20))); QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + // Test a basic float rectangle + p.setClipRect(QRectF(100, 100, 200, 100)); + QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200))); + p.setClipRect(QRectF(120, 120, 20, 20), Qt::IntersectClip); + QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + // Test a basic path + region QPainterPath path; path.addRect(100, 100, 200, 100); -- cgit v0.12