mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:13:25 +00:00
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>
This commit is contained in:
parent
03fc9e3c26
commit
57192063c4
1 changed files with 4 additions and 0 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue