From 543f3ac5844c433c481f42380c4ac344fdadd3bc Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 8 Jun 2014 11:55:03 -0700 Subject: Picture handling: don't add the same picture more than once It confuses us elsewhere (the model suddenly doesn't match the list of pictures as the model doesn't reflect the duplicate pictures). Signed-off-by: Dirk Hohndel --- dive.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'dive.c') diff --git a/dive.c b/dive.c index 19be645b6..5c9d3664d 100644 --- a/dive.c +++ b/dive.c @@ -2272,8 +2272,19 @@ struct picture *alloc_picture() return pic; } +static bool new_picture_for_dive(struct dive *d, char *filename) +{ + FOR_EACH_PICTURE(d) { + if (same_string(picture->filename, filename)) + return false; + } + return true; +} + void dive_create_picture(struct dive *d, char *filename, int shift_time) { + if (!new_picture_for_dive(d, filename)) + return; struct picture *p = alloc_picture(); p->filename = filename; picture_load_exif_data(p); -- cgit v1.2.3-70-g09d2