From 07fd674740b4f80c45c84ad88659f0c4889943e5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 20 Apr 2017 10:01:05 +0200 Subject: Fix painterpath rect intersections with points on the rect QPainterPath could in certain cases where sub-path points were on the border of a rect fail to calculate intersects() correctly. The patch adds handling of such cases by looking if end points cross in or out of the rect. Other cases are already caught. Task-number: QTBUG-31551 Change-Id: I6284da8ff8646d4636702923a76362302dde5767 Reviewed-by: Eirik Aavitsland --- tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index c7203a1b36..757e4d16e4 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -101,6 +101,7 @@ private slots: void lineWithinBounds(); void intersectionEquality(); + void intersectionPointOnEdge(); }; void tst_QPainterPath::cleanupTestCase() @@ -1363,6 +1364,17 @@ void tst_QPainterPath::intersectionEquality() QVERIFY(i1 == i2 || i1.toReversed() == i2); } +void tst_QPainterPath::intersectionPointOnEdge() +{ + // From QTBUG-31551 + QPainterPath p; p.addRoundedRect(-10, 10, 40, 40, 10, 10); + QRectF r(0, 0, 100, 100); + QPainterPath rp; rp.addRect(r); + QVERIFY(!p.intersected(rp).isEmpty()); + QVERIFY(p.intersects(rp)); + QVERIFY(p.intersects(r)); +} + QTEST_APPLESS_MAIN(tst_QPainterPath) #include "tst_qpainterpath.moc" -- cgit v1.2.3