QPainterPath: plug memory leak

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 <robert.loehning@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2021-03-17 18:51:12 +01:00
parent 48ce0bed62
commit 2409e9b2c7

View File

@ -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;
}