From c2c0cb48d2b08935037b37555209571adb7d796e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sun, 1 May 2016 00:00:29 +0200 Subject: Only attempt to download each picture once Otherwise we keep downloading the same image multiple times instead of new images. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- core/imagedownloader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core') diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index dc74a1e27..d4dd85922 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -4,6 +4,7 @@ #include "qthelper.h" #include "imagedownloader.h" #include +#include #include @@ -75,10 +76,17 @@ void ImageDownloader::saveImage(QNetworkReply *reply) } +QSet queuedPictures; +QMutex pictureQueueMutex; + void loadPicture(struct picture *picture, bool fromHash) { if (!picture) return; + QMutexLocker locker(&pictureQueueMutex); + if (queuedPictures.contains(QString(picture->filename))) + return; + queuedPictures.insert(QString(picture->filename)); ImageDownloader download(picture); download.load(fromHash); } -- cgit v1.2.3-70-g09d2