From bade08910bd47e550d3b1ba7ca2a4bc4bba5806e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sun, 1 May 2016 00:00:29 +0200 Subject: [PATCH] Only attempt to download each picture once To: subsurface@subsurface-divelog.org Otherwise we keep downloading the same image multiple times instead of new images. Signed-off-by: Robert C. Helling --- core/imagedownloader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index dc74a1e..d4dd859 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); } -- 2.6.4 (Apple Git-63)