diff options
Diffstat (limited to 'src/gui/painting/qpainterpath_p.h')
-rw-r--r-- | src/gui/painting/qpainterpath_p.h | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index 567f155210..a420e0b3d9 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -62,8 +62,11 @@ #include <private/qvectorpath_p.h> #include <private/qstroker_p.h> +#include <memory> + QT_BEGIN_NAMESPACE +// ### Qt 6: merge with QPainterPathData class QPainterPathPrivate { public: @@ -80,7 +83,19 @@ public: friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &); #endif - QPainterPathPrivate() : ref(1) {} + QPainterPathPrivate() noexcept + : ref(1) + { + } + + QPainterPathPrivate(const QPainterPathPrivate &other) noexcept + : ref(1), + elements(other.elements) + { + } + + QPainterPathPrivate &operator=(const QPainterPathPrivate &) = delete; + ~QPainterPathPrivate() = default; private: QAtomicInt ref; @@ -166,30 +181,30 @@ public: QPainterPathData() : cStart(0), fillRule(Qt::OddEvenFill), + require_moveTo(false), dirtyBounds(false), dirtyControlBounds(false), - pathConverter(0) + convex(false), + pathConverter(nullptr) { - require_moveTo = false; - convex = false; } QPainterPathData(const QPainterPathData &other) : - QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), + QPainterPathPrivate(other), + cStart(other.cStart), + fillRule(other.fillRule), bounds(other.bounds), controlBounds(other.controlBounds), + require_moveTo(false), dirtyBounds(other.dirtyBounds), dirtyControlBounds(other.dirtyControlBounds), convex(other.convex), - pathConverter(0) + pathConverter(nullptr) { - require_moveTo = false; - elements = other.elements; } - ~QPainterPathData() { - delete pathConverter; - } + QPainterPathData &operator=(const QPainterPathData &) = delete; + ~QPainterPathData() = default; inline bool isClosed() const; inline void close(); @@ -198,7 +213,7 @@ public: const QVectorPath &vectorPath() { if (!pathConverter) - pathConverter = new QVectorPathConverter(elements, fillRule, convex); + pathConverter.reset(new QVectorPathConverter(elements, fillRule, convex)); return pathConverter->path; } @@ -213,7 +228,7 @@ public: uint dirtyControlBounds : 1; uint convex : 1; - QVectorPathConverter *pathConverter; + std::unique_ptr<QVectorPathConverter> pathConverter; }; @@ -266,7 +281,7 @@ inline bool QPainterPathData::isClosed() const inline void QPainterPathData::close() { - Q_ASSERT(ref.load() == 1); + Q_ASSERT(ref.loadRelaxed() == 1); require_moveTo = true; const QPainterPath::Element &first = elements.at(cStart); QPainterPath::Element &last = elements.last(); @@ -293,7 +308,7 @@ inline void QPainterPathData::maybeMoveTo() inline void QPainterPathData::clear() { - Q_ASSERT(ref.load() == 1); + Q_ASSERT(ref.loadRelaxed() == 1); elements.clear(); @@ -307,8 +322,7 @@ inline void QPainterPathData::clear() dirtyControlBounds = false; convex = false; - delete pathConverter; - pathConverter = nullptr; + pathConverter.reset(); } #define KAPPA qreal(0.5522847498) |