From 4982389ca762ef4831fc095f00e65e8c7b4bfc1a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 23 Jan 2013 13:19:58 -0800 Subject: Fix setting of the dive_table.preexisting logic The 'preexisting' value is used for downloading dives: we want to add new dives but, but then compare those new dives against the preexisting ones before we start sorting things and possibly merging them. However, the value was only updated sporadically, resulting in it having stale information in it. Which would cause problems particularly if you deleted dives, so that the preexisting value would point past the actual existing values! So just update it unconditionally in dive_list_update_dives(), which anything that changes the dive list is supposed to call in order to display the changes anyway. Also, just for safety, when removing a dive, put NULL in the last dive table location. Nobody should ever access past the end anyway (this is enforced by 'get_dive()') but there are places that access the dive list table directly, and the libdivecomputer download was one of those. No reason to leave stale dive pointers possibly around for uses like that. Reported-by: Henrik Brautaset Aronsen Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 307dd13c1..0e98d9059 100644 --- a/main.c +++ b/main.c @@ -181,6 +181,7 @@ void report_dives(gboolean is_imported, gboolean prefer_imported) add_single_dive(i, merged); delete_single_dive(i+1); delete_single_dive(i+1); + mark_divelist_changed(TRUE); } /* make sure no dives are still marked as downloaded */ for (i = 1; i < dive_table.nr; i++) @@ -195,7 +196,6 @@ void report_dives(gboolean is_imported, gboolean prefer_imported) if (preexisting != dive_table.nr) mark_divelist_changed(TRUE); } - dive_table.preexisting = dive_table.nr; dive_list_update_dives(); } -- cgit v1.2.3-70-g09d2