From c7167509acdba006fe6da4ec1866acb214c18197 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 14 May 2019 20:01:35 +0200 Subject: [PATCH] QPainterPath: convert manual memory management to std::unique_ptr And default the destructor, now that it's empty. Change-Id: I868d4fa04f8e82bc35f2364073d07fa47659b89c Reviewed-by: Marc Mutz --- src/gui/painting/qpainterpath.cpp | 3 +-- src/gui/painting/qpainterpath_p.h | 15 ++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 956b7f5514..42872359d7 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -3499,8 +3499,7 @@ void QPainterPath::setDirty(bool dirty) { d_func()->dirtyBounds = dirty; d_func()->dirtyControlBounds = dirty; - delete d_func()->pathConverter; - d_func()->pathConverter = 0; + d_func()->pathConverter.reset(); d_func()->convex = false; } diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index 8af811499b..4eb541ec65 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -62,6 +62,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE // ### Qt 6: merge with QPainterPathData @@ -202,11 +204,7 @@ public: } QPainterPathData &operator=(const QPainterPathData &) = delete; - - ~QPainterPathData() - { - delete pathConverter; - } + ~QPainterPathData() = default; inline bool isClosed() const; inline void close(); @@ -215,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; } @@ -230,7 +228,7 @@ public: uint dirtyControlBounds : 1; uint convex : 1; - QVectorPathConverter *pathConverter; + std::unique_ptr pathConverter; }; @@ -324,8 +322,7 @@ inline void QPainterPathData::clear() dirtyControlBounds = false; convex = false; - delete pathConverter; - pathConverter = nullptr; + pathConverter.reset(); } #define KAPPA qreal(0.5522847498)