mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-22 06:19:01 +00:00
use a mutex to protect some things in icon
This commit is contained in:
parent
135d0d470d
commit
b4cb329145
@ -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
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user