From 0b4ccbf81ee2009051169f2f0918442b56512b20 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 25 Mar 2021 18:26:49 +0100 Subject: 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 Pick-to: 5.12 5.15 6.0 6.1 Done-with: Milian Wolff Reviewed-by: Eirik Aavitsland --- src/gui/painting/qpainterpath.cpp | 2 +- src/gui/painting/qpainterpath_p.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index bf77fb8b3e..6042106399 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1341,7 +1341,7 @@ void QPainterPath::addRegion(const QRegion ®ion) */ 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 92d0853ba0..5a07e3dc8d 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 = {}; -- cgit v1.2.3