From 10b8bda6626fe1de602e38da34de419972031755 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Thu, 15 Dec 2016 14:31:20 +0100 Subject: Fix picture hashing logic for pictures on the web. Signed-off-by: Robert C. Helling --- core/qthelper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/qthelper.cpp') diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 885e89d98..088067f26 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -1075,6 +1075,8 @@ QByteArray hashFile(const QString filename) void learnHash(struct picture *picture, QByteArray hash) { + if (hash.isNull()) + return; if (picture->hash) free(picture->hash); QMutexLocker locker(&hashOfMutex); @@ -1100,6 +1102,8 @@ QString localFilePath(const QString originalFilename) QString fileFromHash(char *hash) { + if (!hash || !*hash) + return ""; QMutexLocker locker(&hashOfMutex); return localFilenameOf[QByteArray::fromHex(hash)]; @@ -1120,7 +1124,7 @@ void hashPicture(struct picture *picture) if (!picture) return; char *oldHash = copy_string(picture->hash); - learnHash(picture, hashFile(QString(picture->filename))); + learnHash(picture, hashFile(localFilePath(picture->filename))); if (!same_string(picture->hash, "") && !same_string(picture->hash, oldHash)) mark_divelist_changed((true)); free(oldHash); -- cgit v1.2.3-70-g09d2