From 1704e0801258d0ae78b18be32488e083458010f1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Date: Sun, 28 Jan 2018 21:50:25 +0100 Subject: [PATCH] Make future_watcher a subobject of NotificationWidget This was a raw pointer. No point in doing error-prone manual memory management. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> --- desktop-widgets/notificationwidget.cpp | 10 ++-------- desktop-widgets/notificationwidget.h | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/desktop-widgets/notificationwidget.cpp b/desktop-widgets/notificationwidget.cpp index 952adef4f..e0227010c 100644 --- a/desktop-widgets/notificationwidget.cpp +++ b/desktop-widgets/notificationwidget.cpp @@ -3,8 +3,7 @@ NotificationWidget::NotificationWidget(QWidget *parent) : KMessageWidget(parent) { - future_watcher = new QFutureWatcher<void>(); - connect(future_watcher, SIGNAL(finished()), this, SLOT(finish())); + connect(&future_watcher, SIGNAL(finished()), this, SLOT(finish())); } void NotificationWidget::showNotification(QString message, KMessageWidget::MessageType type) @@ -29,15 +28,10 @@ QString NotificationWidget::getNotificationText() void NotificationWidget::setFuture(const QFuture<void> &future) { - future_watcher->setFuture(future); + future_watcher.setFuture(future); } void NotificationWidget::finish() { hideNotification(); } - -NotificationWidget::~NotificationWidget() -{ - delete future_watcher; -} diff --git a/desktop-widgets/notificationwidget.h b/desktop-widgets/notificationwidget.h index 90b3e3c43..70d94b8d6 100644 --- a/desktop-widgets/notificationwidget.h +++ b/desktop-widgets/notificationwidget.h @@ -20,10 +20,9 @@ public: void showNotification(QString message, KMessageWidget::MessageType type); void hideNotification(); QString getNotificationText(); - ~NotificationWidget(); private: - QFutureWatcher<void> *future_watcher; + QFutureWatcher<void> future_watcher; private slots: