summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-24 22:06:09 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-08-16 08:19:01 +0300
commit45c5cc619933d1283da27a15d5d7ab3d2e8e5329 (patch)
treeae3cd2aa6447a1bcccc77733d654f10871f9f001 /src
parent19ccbdabfe889fccd67ab162bbb144846ab098fb (diff)
QWidget: replace manual memory management with unique_ptr [4/N]: extra->curs
Change-Id: Id65ead5563321b8edbe0055ad1531c2442d4d597 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidget.cpp16
-rw-r--r--src/widgets/kernel/qwidget_p.h2
2 files changed, 4 insertions, 14 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 78a8af62df..aa93ee6be2 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1824,9 +1824,6 @@ void QWidgetPrivate::createExtra()
#if QT_CONFIG(graphicsview)
extra->proxyWidget = 0;
#endif
-#ifndef QT_NO_CURSOR
- extra->curs = 0;
-#endif
extra->minw = 0;
extra->minh = 0;
extra->maxw = QWIDGETSIZE_MAX;
@@ -1860,9 +1857,6 @@ void QWidgetPrivate::createSysExtra()
void QWidgetPrivate::deleteExtra()
{
if (extra) { // if exists
-#ifndef QT_NO_CURSOR
- delete extra->curs;
-#endif
deleteSysExtra();
#ifndef QT_NO_STYLE_STYLESHEET
// dereference the stylesheet style
@@ -5019,9 +5013,7 @@ void QWidget::setCursor(const QCursor &cursor)
#endif
{
d->createExtra();
- QCursor *newCursor = new QCursor(cursor);
- delete d->extra->curs;
- d->extra->curs = newCursor;
+ d->extra->curs = qt_make_unique<QCursor>(cursor);
}
setAttribute(Qt::WA_SetCursor);
d->setCursor_sys(cursor);
@@ -5040,10 +5032,8 @@ void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
void QWidget::unsetCursor()
{
Q_D(QWidget);
- if (d->extra) {
- delete d->extra->curs;
- d->extra->curs = 0;
- }
+ if (d->extra)
+ d->extra->curs.reset();
if (!isWindow())
setAttribute(Qt::WA_SetCursor, false);
d->unsetCursor_sys();
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index b43489a98f..03b09f2ca8 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -244,7 +244,7 @@ struct QWExtra {
QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
#endif
#ifndef QT_NO_CURSOR
- QCursor *curs;
+ std::unique_ptr<QCursor> curs;
#endif
QPointer<QStyle> style;
QPointer<QWidget> focus_proxy;