mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
3c7e14a18f
commit
8a59d78faa
5 changed files with 30 additions and 6 deletions
|
@ -3374,7 +3374,7 @@ void dive_set_geodata_from_picture(struct dive *dive, struct picture *picture)
|
|||
}
|
||||
}
|
||||
|
||||
static void picture_free(struct picture *picture)
|
||||
void picture_free(struct picture *picture)
|
||||
{
|
||||
if (!picture)
|
||||
return;
|
||||
|
@ -3383,6 +3383,18 @@ static void picture_free(struct picture *picture)
|
|||
free(picture);
|
||||
}
|
||||
|
||||
// When handling pictures in different threads, we need to copy them so we don't
|
||||
// run into problems when the main thread frees the picture.
|
||||
|
||||
struct picture *clone_picture(struct picture *src)
|
||||
{
|
||||
struct picture *dst;
|
||||
|
||||
dst = alloc_picture();
|
||||
copy_pl(src, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
void dive_remove_picture(char *filename)
|
||||
{
|
||||
struct picture **picture = ¤t_dive->picture_list;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue