summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-03 10:30:48 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-03 10:30:48 -0700
commit1f252fedd1c53bb347ff79740f6dcad32691f0cd (patch)
tree31c4dc85494bce0a15b9d2df20258548ff3c77a9
parent8b021de8d9838f4591b50cb15fc8774c31f8ed14 (diff)
downloadsubsurface-1f252fedd1c53bb347ff79740f6dcad32691f0cd.tar.gz
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>
-rw-r--r--divelist.c3
1 files changed, 2 insertions, 1 deletions
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);