From b4cb329145532af070e3e6d41581ad7c4d63c239 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Wed, 15 Jan 2014 18:49:12 +0100 Subject: [PATCH] use a mutex to protect some things in icon --- src/core/notification/icon_p.cpp | 9 ++++++--- src/core/notification/icon_p.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/notification/icon_p.cpp b/src/core/notification/icon_p.cpp index dc178aa..3340f77 100644 --- a/src/core/notification/icon_p.cpp +++ b/src/core/notification/icon_p.cpp @@ -60,6 +60,7 @@ IconData::~IconData() const QByteArray &Snore::IconData::imageData() { + QMutexLocker lock(&m_mutex); if(m_data.isEmpty()) { if(m_isRemoteFile) @@ -72,6 +73,7 @@ const QByteArray &Snore::IconData::imageData() const QImage &IconData::image() { + QMutexLocker lock(&m_mutex); if(m_img.isNull()) { if(!m_isRemoteFile ) @@ -89,6 +91,7 @@ const QImage &IconData::image() QString IconData::localUrl() { + QMutexLocker lock(&m_mutex); if(!m_isLocalFile && !QFile(m_localUrl).exists()) { image().save(m_localUrl ,"PNG"); @@ -114,9 +117,9 @@ void IconData::download() loop.exec(); if(reply->isFinished()) { - m_data = reply->readAll(); - m_img = QImage::fromData(m_data, "PNG"); - m_img.save(m_localUrl,"PNG"); + m_data = reply->readAll(); + m_img = QImage::fromData(m_data, "PNG"); + m_img.save(m_localUrl,"PNG"); } } else diff --git a/src/core/notification/icon_p.h b/src/core/notification/icon_p.h index 953626a..d902dd5 100644 --- a/src/core/notification/icon_p.h +++ b/src/core/notification/icon_p.h @@ -29,6 +29,8 @@ #include #include +#include + namespace Snore{ class IconData : public QSharedData @@ -61,6 +63,7 @@ public: bool m_isLocalFile; bool m_isResource; bool m_isRemoteFile; + QMutex m_mutex; private: Q_DISABLE_COPY(IconData)