summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-03-25 18:26:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-26 14:38:28 +0000
commit9c12d8e8f76446149ec0ac11da0d4ebf61a18cf4 (patch)
treea43b64d2a8c80a1fef6d10dc8889612403a90eb4
parent9d1b1c71b29ed4c84195093c68c45f77796fb62f (diff)
QPainterPath: fix handling of fill rules
fillRule() contained a major blunder: instead of checking if the d-pointer was allocated, and return a default value if it wasn't, it checked whether the path contained any points. This means that QPainterPath p; p.setFillRule(x); Q_ASSERT(p.fillRule() == x); was failing. As a drive-by to test this change, fix another mistake in clear(): clear is documented to clear the elements in a path, but instead it also changed the fill rule. This commit partially reverses 697910e5fbd382e78bc1bcbac3f5824aded059b4. Change-Id: Ieb8145694b672439c3380d9ccb87d1206a2dd115 Done-with: Milian Wolff Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 0b4ccbf81ee2009051169f2f0918442b56512b20) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/painting/qpainterpath.cpp2
-rw-r--r--src/gui/painting/qpainterpath_p.h1
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp12
3 files changed, 12 insertions, 3 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 38acc66ba4..9479cadd8f 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1369,7 +1369,7 @@ void QPainterPath::addRegion(const QRegion &region)
*/
Qt::FillRule QPainterPath::fillRule() const
{
- return isEmpty() ? Qt::OddEvenFill : d_func()->fillRule;
+ return !d_func() ? Qt::OddEvenFill : d_func()->fillRule;
}
/*!
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 24feaf410b..c283b7f27e 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -292,7 +292,6 @@ inline void QPainterPathPrivate::clear()
elements.clear();
cStart = 0;
- fillRule = Qt::OddEvenFill;
bounds = {};
controlBounds = {};
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index 12a8fff33b..dcba95d33c 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -173,8 +173,18 @@ void tst_QPainterPath::clear()
p1.setFillRule(Qt::WindingFill);
QVERIFY(p1 != p3);
p1.clear();
- QCOMPARE(p1.fillRule(), Qt::OddEvenFill);
+ QVERIFY(p1 != p3);
+ p1.setFillRule(Qt::OddEvenFill);
QCOMPARE(p1, p2);
+
+ QPainterPath p4;
+ QCOMPARE(p4.fillRule(), Qt::OddEvenFill);
+ p4.setFillRule(Qt::WindingFill);
+ QCOMPARE(p4.fillRule(), Qt::WindingFill);
+ p4.clear();
+ QCOMPARE(p4.fillRule(), Qt::WindingFill);
+ p4 = QPainterPath();
+ QCOMPARE(p4.fillRule(), Qt::OddEvenFill);
}
void tst_QPainterPath::reserveAndCapacity()