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>
This commit is contained in:
Berthold Stoeger 2018-01-28 21:50:25 +01:00 committed by Jan Mulder
parent 5a9faf2fea
commit 1704e08012
2 changed files with 3 additions and 10 deletions

View file

@ -3,8 +3,7 @@
NotificationWidget::NotificationWidget(QWidget *parent) : KMessageWidget(parent) 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) void NotificationWidget::showNotification(QString message, KMessageWidget::MessageType type)
@ -29,15 +28,10 @@ QString NotificationWidget::getNotificationText()
void NotificationWidget::setFuture(const QFuture<void> &future) void NotificationWidget::setFuture(const QFuture<void> &future)
{ {
future_watcher->setFuture(future); future_watcher.setFuture(future);
} }
void NotificationWidget::finish() void NotificationWidget::finish()
{ {
hideNotification(); hideNotification();
} }
NotificationWidget::~NotificationWidget()
{
delete future_watcher;
}

View file

@ -20,10 +20,9 @@ public:
void showNotification(QString message, KMessageWidget::MessageType type); void showNotification(QString message, KMessageWidget::MessageType type);
void hideNotification(); void hideNotification();
QString getNotificationText(); QString getNotificationText();
~NotificationWidget();
private: private:
QFutureWatcher<void> *future_watcher; QFutureWatcher<void> future_watcher;
private private
slots: slots: