From 2409e9b2c7ca433ac1183efb763fdb99edf59235 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 17 Mar 2021 18:51:12 +0100 Subject: [PATCH] QPainterPath: plug memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The copy operations didn't take into account the recent upgrade to QESDP, just reimplement them idiomatically and thus avoid a leak. Change-Id: I796c02b7d7835cfecd8e097c9979a6d431ee3f07 Fixes: QTBUG-91916 Reviewed-by: Robert Löhning Reviewed-by: Volker Hilsheimer --- src/gui/painting/qpainterpath.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 46a525b7a0..bf77fb8b3e 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -545,12 +545,7 @@ QPainterPath::QPainterPath() noexcept \sa operator=() */ -QPainterPath::QPainterPath(const QPainterPath &other) - : d_ptr(other.d_ptr.data()) -{ - if (d_ptr) - d_ptr->ref.ref(); -} +QPainterPath::QPainterPath(const QPainterPath &other) = default; /*! Creates a QPainterPath object with the given \a startPoint as its @@ -592,12 +587,8 @@ void QPainterPath::ensureData_helper() */ QPainterPath &QPainterPath::operator=(const QPainterPath &other) { - if (other.d_func() != d_func()) { - QPainterPathPrivate *data = other.d_func(); - if (data) - data->ref.ref(); - d_ptr.reset(data); - } + QPainterPath copy(other); + swap(copy); return *this; }