QWidget: replace manual memory management with unique_ptr [2/N]: topextra->icon
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 <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
94d7603d51
commit
d473f216b9
|
|
@ -121,6 +121,8 @@
|
|||
|
||||
#include <QtPlatformHeaders/qxcbwindowfunctions.h>
|
||||
|
||||
#include <private/qmemory_p.h>
|
||||
|
||||
// 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<QIcon>(icon);
|
||||
else
|
||||
*d->extra->topextra->icon = icon;
|
||||
|
||||
d->setWindowIcon_sys();
|
||||
d->setWindowIcon_helper();
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ struct QTLWExtra {
|
|||
// *************************** Cross-platform variables *****************************
|
||||
|
||||
// Regular pointers (keep them together to avoid gaps on 64 bits architectures).
|
||||
QIcon *icon; // widget icon
|
||||
std::unique_ptr<QIcon> icon; // widget icon
|
||||
QWidgetBackingStoreTracker backingStoreTracker;
|
||||
QBackingStore *backingStore;
|
||||
QPainter *sharedPainter;
|
||||
|
|
|
|||
Loading…
Reference in New Issue