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 <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-09-03 10:30:48 -07:00
parent 8b021de8d9
commit 1f252fedd1

View file

@ -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);