diff options
| author | 2016-03-16 00:29:28 +0100 | |
|---|---|---|
| committer | 2016-03-15 22:38:47 -0700 | |
| commit | 2639281354445f0e37b5dd2e6927155361aaf792 (patch) | |
| tree | e7f32a03449941d9789d669760d4b327eeb99ad7 /qthelper.cpp | |
| parent | 2368f3371bbdb587888d5f04095623c7b8b2ac2e (diff) | |
| download | subsurface-2639281354445f0e37b5dd2e6927155361aaf792.tar.gz | |
Copy picture struct for worker thread
This copies the picture struct when delegating image handling
to a worker thread to prevent a crashe when main thread
frees the picture upon selecting a different dive.
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 | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index 67ce5daff..745fc5f60 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -1182,9 +1182,11 @@ void learnHash(struct picture *picture, QByteArray hash) QString localFilePath(const QString originalFilename) { - if (hashOf.contains(originalFilename) && localFilenameOf.contains(hashOf[originalFilename])) - return localFilenameOf[hashOf[originalFilename]]; - else + if (hashOf.contains(originalFilename)) + if (localFilenameOf.contains(hashOf[originalFilename])) + if (localFilenameOf[hashOf[originalFilename]] != "") + return localFilenameOf[hashOf[originalFilename]]; + return originalFilename; } @@ -1200,6 +1202,7 @@ void updateHash(struct picture *picture) { char *old = picture->hash; picture->hash = strdup(hash.toHex()); free(old); + picture_free(picture); } void hashPicture(struct picture *picture) @@ -1209,13 +1212,14 @@ void hashPicture(struct picture *picture) if (!same_string(picture->hash, "") && !same_string(picture->hash, oldHash)) mark_divelist_changed((true)); free(oldHash); + picture_free(picture); } extern "C" void cache_picture(struct picture *picture) { QString filename = picture->filename; if (!hashOf.contains(filename)) - QtConcurrent::run(hashPicture, picture); + QtConcurrent::run(hashPicture, clone_picture(picture)); } void learnImages(const QDir dir, int max_recursions, bool recursed) |