diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-03-25 14:28:36 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-03-30 13:03:56 -0700 |
commit | 57192063c45db1e943bda9ff284f85570a2efd0d (patch) | |
tree | 11b9e9eeeeac9678300c791c4da8d83e87733d10 /qthelper.cpp | |
parent | 03fc9e3c264b1b5d62af702cf755a8008469fe13 (diff) | |
download | subsurface-57192063c45db1e943bda9ff284f85570a2efd0d.tar.gz |
Protect writing to image hashes with a mutex
Hopefully...
Fixes #861
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r-- | qthelper.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index 8ca15f7aa..eb0d5e41a 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -805,6 +805,7 @@ extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32 } QHash<QString, QByteArray> hashOf; +QMutex hashOfMutex; QHash<QByteArray, QString> localFilenameOf; extern "C" char * hashstring(char * filename) @@ -836,6 +837,7 @@ void write_hashes() void add_hash(const QString filename, QByteArray hash) { + QMutexLocker locker(&hashOfMutex); hashOf[filename] = hash; localFilenameOf[hash] = filename; } @@ -853,6 +855,7 @@ QByteArray hashFile(const QString filename) void learnHash(struct picture *picture, QByteArray hash) { free(picture->hash); + QMutexLocker locker(&hashOfMutex); hashOf[QString(picture->filename)] = hash; picture->hash = strdup(hash.toHex()); } @@ -869,6 +872,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()); |