summaryrefslogtreecommitdiffstats
path: root/subsurface-core/dive.c
diff options
context:
space:
mode:
Diffstat (limited to 'subsurface-core/dive.c')
-rw-r--r--subsurface-core/dive.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/subsurface-core/dive.c b/subsurface-core/dive.c
index 47b3e1f06..cad2a85cc 100644
--- a/subsurface-core/dive.c
+++ b/subsurface-core/dive.c
@@ -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 = &current_dive->picture_list;