fix QTimer issues

This commit is contained in:
Patrick von Reth 2015-07-15 16:05:16 +02:00
parent d310cb821c
commit 74a500efa9
3 changed files with 5 additions and 5 deletions

View File

@ -67,6 +67,7 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString
NotificationData::~NotificationData()
{
stopTimeoutTimer();
notificationCount--;
snoreDebug(SNORE_INFO) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason;
}
@ -127,9 +128,7 @@ bool NotificationData::sourceAndTargetAreSimilar(const SnorePlugin *target)
void NotificationData::stopTimeoutTimer()
{
if (m_timeoutTimer) {
m_timeoutTimer->stop();
m_timeoutTimer->deleteLater();
m_timeoutTimer.reset(nullptr);
QMetaObject::invokeMethod(m_timeoutTimer.data(), "deleteLater", Qt::QueuedConnection);
}
}

View File

@ -23,6 +23,7 @@
#include "notification.h"
#include "../hint.h"
#include <QPointer>
#include <QSharedData>
#include <QTimer>
@ -87,7 +88,7 @@ private:
QHash<int, Action> m_actions;
Hint m_hints;
Notification m_toReplace;
QScopedPointer<QTimer> m_timeoutTimer;
QPointer<QTimer> m_timeoutTimer;
QSet<const QObject *> m_activeIn;
bool m_isBroadcasted = false;
SnorePlugin *m_source = nullptr;

View File

@ -237,7 +237,7 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
notification.data()->stopTimeoutTimer();
QTimer *timer = new QTimer();
notification.data()->m_timeoutTimer.reset(timer);
notification.data()->m_timeoutTimer = timer;
timer->setSingleShot(true);
if (notification.isUpdate()) {