From b750a48f0f834dcf33fc2518c877f498f3b3cff5 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 18 Feb 2018 14:07:15 +0100 Subject: Cleanup: Don't store hash in picture struct in learnHash() learnHash() is called either on a local picture structure [DiveListView::loadImageFromURL()] or on a cloned picture structure [ImageDownloader::saveImage()]. In neither case the picture structure is passed to the frontend. Therefore, storing the new hash in the picture struct is not necessary. Signed-off-by: Berthold Stoeger --- core/qthelper.cpp | 5 +---- core/qthelper.h | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/qthelper.cpp b/core/qthelper.cpp index e7bf7dcf4..0029ca13a 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -1149,15 +1149,12 @@ QByteArray hashFile(const QString filename) } } -void learnHash(struct picture *picture, QByteArray hash) +void learnHash(const struct picture *picture, QByteArray hash) { if (hash.isNull()) return; - if (picture->hash) - free(picture->hash); QMutexLocker locker(&hashOfMutex); hashOf[QString(picture->filename)] = hash; - picture->hash = strdup(hash.toHex()); } static bool haveHash(const QString &filename) diff --git a/core/qthelper.h b/core/qthelper.h index f84c74d2b..a71960c86 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -37,9 +37,10 @@ QByteArray hashFile(const QString filename); void learnImages(const QDir dir, int max_recursions); void add_hash(const QString filename, QByteArray hash); void hashPicture(struct picture *picture); +extern "C" char *hashstring(const char *filename); QString localFilePath(const QString originalFilename); QString fileFromHash(const char *hash); -void learnHash(struct picture *picture, QByteArray hash); +void learnHash(const struct picture *picture, QByteArray hash); weight_t string_to_weight(const char *str); depth_t string_to_depth(const char *str); pressure_t string_to_pressure(const char *str); -- cgit v1.2.3-70-g09d2