diff options
author | Robert C. Helling <helling@atdotde.de> | 2016-03-15 21:31:59 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-03-16 07:46:28 -0700 |
commit | 8a59d78faa4792934a11a774c9dffcd85f0c3340 (patch) | |
tree | 5d38fc9d40712e2314759ff05ff0c0b58145fee6 /subsurface-core/imagedownloader.cpp | |
parent | 3c7e14a18fdc2ee9590e591afe4761a2d93881e7 (diff) | |
download | subsurface-8a59d78faa4792934a11a774c9dffcd85f0c3340.tar.gz |
When handing off a picture to a worker thread, copy it first
as otherwise we crash when the picture is freed before the
worker thread (to load from the net or to compute hashes)
is finished
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/imagedownloader.cpp')
-rw-r--r-- | subsurface-core/imagedownloader.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/subsurface-core/imagedownloader.cpp b/subsurface-core/imagedownloader.cpp index 9451f8a1b..d28ec9503 100644 --- a/subsurface-core/imagedownloader.cpp +++ b/subsurface-core/imagedownloader.cpp @@ -17,6 +17,11 @@ ImageDownloader::ImageDownloader(struct picture *pic) picture = pic; } +ImageDownloader::~ImageDownloader() +{ + picture_free(picture); +} + void ImageDownloader::load(bool fromHash){ QUrl url; if(fromHash) @@ -79,21 +84,21 @@ SHashedImage::SHashedImage(struct picture *picture) : QImage() if (filename.isNull()) { // That didn't produce a local filename. // Try the cloud server - QtConcurrent::run(loadPicture, picture, true); + QtConcurrent::run(loadPicture, clone_picture(picture), true); } else { // Load locally from translated file name load(filename); if (!isNull()) { // Make sure the hash still matches the image file - QtConcurrent::run(updateHash, picture); + QtConcurrent::run(updateHash, clone_picture(picture)); } else { // Interpret filename as URL - QtConcurrent::run(loadPicture, picture, false); + QtConcurrent::run(loadPicture, clone_picture(picture), false); } } } else { // We loaded successfully. Now, make sure hash is up to date. - QtConcurrent::run(hashPicture, picture); + QtConcurrent::run(hashPicture, clone_picture(picture)); } } |