Hi,

Am 27.11.2016 um 11:59 schrieb Robert Helling <[email protected]>:

Let me see if we can detect this cache corruption (i.e. when the cached thumbnail does not open as an image) or provide a way to the user to invalidate the cache.


my suspicion is that it was not the thumbnail cache that was corrupted but rather the two table translating hashes to local file names and vice versa had entries with empty hash strings (which aren’t valid hashes of course).

Here is a patch hat gets rid of those.

From fa0a376bf392098ae41131357fd17d80b6887845 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Fri, 2 Dec 2016 23:43:30 +0100
Subject: [PATCH] Empty image hashes are not valid
To: [email protected]

I don't know how those arose in the first place, but an
empty QByteArray is never a valid hash value for an image. So
we should not store those in our translation tables and also
get rid of them when loading the tables from disk.

Signed-off-by: Robert C. Helling <[email protected]>
---
 core/qthelper.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 0628dd2..ad17801 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1026,6 +1026,20 @@ void read_hashes()
                stream >> thumbnailCache;
                hashfile.close();
        }
+       localFilenameOf.remove("");
+       QMutableHashIterator<QString, QByteArray> iter(hashOf);
+       while (iter.hasNext()) {
+               iter.next();
+               if (iter.value().isEmpty())
+                       iter.remove();
+       }
+       qDebug() << "localFilenameOf empty" << localFilenameOf[""];
+
+       QHash<QString, QImage>::const_iterator i = thumbnailCache.constBegin();
+       while (i != thumbnailCache.constEnd()) {
+               qDebug() << i.key() << *i;
+               ++i;
+       }
 }
 
 void write_hashes()
@@ -1046,6 +1060,8 @@ void write_hashes()
 
 void add_hash(const QString filename, QByteArray hash)
 {
+       if (hash.isEmpty())
+               return;
        QMutexLocker locker(&hashOfMutex);
        hashOf[filename] =  hash;
        localFilenameOf[hash] = filename;
-- 
2.9.3 (Apple Git-75)


Best 
Robert

PS: Dirk, it seems master still lacks my last patch fixing the calculation of the effective gradient factors (sum > 1 rather than sum>0).

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