fixed qtimer warning and possible crash caused by QScopedPointer deleting QTimer directly instead with deleteLater

This commit is contained in:
Patrick von Reth 2014-08-24 11:14:51 +02:00
parent cc5739c994
commit e70a6c8fa8
2 changed files with 7 additions and 3 deletions

View File

@ -68,6 +68,10 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString
NotificationData::~NotificationData() NotificationData::~NotificationData()
{ {
if(!m_timeoutTimer.isNull())
{
m_timeoutTimer->deleteLater();
}
notificationCount--; notificationCount--;
snoreDebug( SNORE_DEBUG ) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason; snoreDebug( SNORE_DEBUG ) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason;
} }
@ -102,7 +106,7 @@ QTimer *NotificationData::timeoutTimer()
{ {
if(m_timeoutTimer.isNull()) if(m_timeoutTimer.isNull())
{ {
m_timeoutTimer.reset(new QTimer()); m_timeoutTimer = new QTimer();
m_timeoutTimer->setSingleShot(true); m_timeoutTimer->setSingleShot(true);
m_timeoutTimer->setProperty("notificationID", m_id); m_timeoutTimer->setProperty("notificationID", m_id);
} }

View File

@ -27,7 +27,7 @@
#include <QSharedData> #include <QSharedData>
#include <QTimer> #include <QTimer>
#include <QScopedPointer> #include <QPointer>
namespace Snore{ namespace Snore{
@ -76,7 +76,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;