diff options
author | Robert C. Helling <helling@atdotde.de> | 2016-05-01 00:00:29 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-30 16:18:44 -0700 |
commit | c2c0cb48d2b08935037b37555209571adb7d796e (patch) | |
tree | a4bf808c930fe7547bf98100b54c2217d3808b84 /core | |
parent | 4a9b97e4a94b1fcff7fe30eb541018dfb4a41d8c (diff) | |
download | subsurface-c2c0cb48d2b08935037b37555209571adb7d796e.tar.gz |
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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/imagedownloader.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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 <unistd.h> +#include <QString> #include <QtConcurrent> @@ -75,10 +76,17 @@ void ImageDownloader::saveImage(QNetworkReply *reply) } +QSet<QString> 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); } |