From 2d28764584bf07d8bab891b41bd520a43e88489a Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sat, 9 Jan 2016 16:27:23 +0100 Subject: [PATCH 1/3] Simplify image hashing logic To: subsurface@subsurface-divelog.org Signed-off-by: Robert C. Helling --- subsurface-core/qthelper.cpp | 6 +----- subsurface-core/qthelper.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp index bddfd76..0a0aeda 100644 --- a/subsurface-core/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -1347,11 +1347,7 @@ QString fileFromHash(char *hash) void updateHash(struct picture *picture) { QByteArray hash = hashFile(fileFromHash(picture->hash)); - QMutexLocker locker(&hashOfMutex); - hashOf[QString(picture->filename)] = hash; - char *old = picture->hash; - picture->hash = strdup(hash.toHex()); - free(old); + learnHash(picture, hash); } void hashPicture(struct picture *picture) diff --git a/subsurface-core/qthelper.h b/subsurface-core/qthelper.h index 0049e9b..b27e0a2 100644 --- a/subsurface-core/qthelper.h +++ b/subsurface-core/qthelper.h @@ -129,6 +129,7 @@ void updateHash(struct picture *picture); QByteArray hashFile(const QString filename); void learnImages(const QDir dir, int max_recursions, bool recursed); void add_hash(const QString filename, QByteArray hash); +void hashPicture(struct picture *picture); QString localFilePath(const QString originalFilename); QString fileFromHash(char *hash); void learnHash(struct picture *picture, QByteArray hash); -- 2.5.4 (Apple Git-61)