From bade08910bd47e550d3b1ba7ca2a4bc4bba5806e Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sun, 1 May 2016 00:00:29 +0200
Subject: [PATCH] Only attempt to download each picture once
To: [email protected]

Otherwise we keep downloading the same image multiple times instead
of new images.

Signed-off-by: Robert C. Helling <[email protected]>
---
 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 <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);
 }
-- 
2.6.4 (Apple Git-63)

So far, we queued pictures of downloads upon trying to display them and not 
finding them locally. This patch checks if the image is already queued for 
download before attempting to do it.

Best
Robert

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to