From f73e5b726808675ec3a02fe57f063b666e0706ac Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 18 Sep 2012 19:37:03 -0400 Subject: [PATCH] When deleting dives make sure that amount_selected stays consistent This could cause a crash if deleting the last dive and manually adding a new one. Reported-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- divelist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/divelist.c b/divelist.c index fb076a81b..514fdfed1 100644 --- a/divelist.c +++ b/divelist.c @@ -1754,13 +1754,16 @@ static void delete_dive_cb(GtkWidget *menuitem, GtkTreePath *path) dive_table.nr--; free(dive); dive_list_update_dives(); - /* now make sure the same dives stay selected and if necessary their trips are expanded */ + /* now make sure the same dives stay selected and if necessary their trips are expanded + * also make sure that amount_selected stays consistent */ + amount_selected = 0; for_each_dive(i, dive) { if (dive->selected) { GtkTreePath *path = get_path_from(dive); if (MODEL(dive_list) == TREEMODEL(dive_list)) gtk_tree_view_expand_to_path(tree_view, path); gtk_tree_selection_select_path(selection, path); + amount_selected++; } } mark_divelist_changed(TRUE);