From 1f252fedd1c53bb347ff79740f6dcad32691f0cd Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 3 Sep 2012 10:30:48 -0700 Subject: [PATCH] Fix crash when removing the first dive of a trip The update_trip_timestamp function can indeed get called with no children present, just before that trip is then removed. So instead of adding complicated special cases, this just bails out of the function. Reported-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- divelist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/divelist.c b/divelist.c index 1c5db5d9b..de7304520 100644 --- a/divelist.c +++ b/divelist.c @@ -1258,7 +1258,8 @@ static void update_trip_timestamp(GtkTreeIter *parent, struct dive *divetrip) int nr; time_t t1, t2, tnew; - if (gtk_tree_store_iter_depth(STORE(dive_list), parent) != 0) + if (gtk_tree_store_iter_depth(STORE(dive_list), parent) != 0 || + gtk_tree_model_iter_n_children(MODEL(dive_list), parent) == 0) return; nr = gtk_tree_model_iter_n_children(MODEL(dive_list), parent); gtk_tree_model_iter_nth_child(MODEL(dive_list), &first_child, parent, 0);