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() NotificationData::~NotificationData()
{ {
stopTimeoutTimer();
notificationCount--; notificationCount--;
snoreDebug(SNORE_INFO) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason; 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() void NotificationData::stopTimeoutTimer()
{ {
if (m_timeoutTimer) { if (m_timeoutTimer) {
m_timeoutTimer->stop(); QMetaObject::invokeMethod(m_timeoutTimer.data(), "deleteLater", Qt::QueuedConnection);
m_timeoutTimer->deleteLater();
m_timeoutTimer.reset(nullptr);
} }
} }

View File

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

View File

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