From d473f216b9a34a0e6272533dc11e885eebfe4191 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 May 2019 22:06:09 +0200 Subject: QWidget: replace manual memory management with unique_ptr [2/N]: topextra->icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I wonder whether a QIcon could be aggregated here by value, as it has a null state and its default ctor sets d = nullptr. Change-Id: I7a0f46e9fdd51a93afb5db768d46d93b08f307ec Reviewed-by: Edward Welbourne Reviewed-by: MÃ¥rten Nordheim --- src/widgets/kernel/qwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/widgets/kernel/qwidget.cpp') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c63bf26b26..68ce8d5d15 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -121,6 +121,8 @@ #include +#include + // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG //#define ALIEN_DEBUG @@ -1784,7 +1786,6 @@ void QWidgetPrivate::createTLExtra() createExtra(); if (!extra->topextra) { QTLWExtra* x = extra->topextra = new QTLWExtra; - x->icon = 0; x->backingStore = 0; x->sharedPainter = 0; x->incw = x->inch = 0; @@ -1872,7 +1873,6 @@ void QWidgetPrivate::deleteExtra() if (extra->topextra) { deleteTLSysExtra(); // extra->topextra->backingStore destroyed in QWidgetPrivate::deleteTLSysExtra() - delete extra->topextra->icon; delete extra->topextra; } delete extra; @@ -6265,8 +6265,9 @@ void QWidget::setWindowIcon(const QIcon &icon) d->createTLExtra(); if (!d->extra->topextra->icon) - d->extra->topextra->icon = new QIcon(); - *d->extra->topextra->icon = icon; + d->extra->topextra->icon = qt_make_unique(icon); + else + *d->extra->topextra->icon = icon; d->setWindowIcon_sys(); d->setWindowIcon_helper(); -- cgit v1.2.3