aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/qthelper.cpp5
-rw-r--r--core/qthelper.h3
-rw-r--r--tests/testpicture.cpp5
3 files changed, 5 insertions, 8 deletions
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);
diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp
index 38e8e3d5b..94b1fe0ee 100644
--- a/tests/testpicture.cpp
+++ b/tests/testpicture.cpp
@@ -43,9 +43,8 @@ void TestPicture::addPicture()
QVERIFY(pic2->hash == NULL);
learnHash(pic1, hashFile(localFilePath(pic1->filename)));
learnHash(pic2, hashFile(localFilePath(pic2->filename)));
- QCOMPARE(pic1->hash, "929ad9499b7ae7a9e39ef63eb6c239604ac2adfa");
- QCOMPARE(pic2->hash, "fa8bd48f8f24017a81e1204f52300bd98b43d4a7");
-
+ QCOMPARE(hashstring(pic1->filename), "929ad9499b7ae7a9e39ef63eb6c239604ac2adfa");
+ QCOMPARE(hashstring(pic2->filename), "fa8bd48f8f24017a81e1204f52300bd98b43d4a7");
}