summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--divelist.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/divelist.c b/divelist.c
index 602c3bc96..b16f53331 100644
--- a/divelist.c
+++ b/divelist.c
@@ -1260,12 +1260,19 @@ static void fill_dive_list(void)
DIVE_DURATION, 0,
-1);
} else {
- int index = trip->index;
+ int idx, ok;
GtkTreeModel *model = TREEMODEL(dive_list);
- gtk_tree_model_get_iter_first(model, &lookup);
- while (--index)
- gtk_tree_model_iter_next(model, &lookup);
- parent_ptr = &lookup;
+
+ parent_ptr = NULL;
+ ok = gtk_tree_model_get_iter_first(model, &lookup);
+ while (ok) {
+ gtk_tree_model_get(model, &lookup, DIVE_INDEX, &idx, -1);
+ if (idx == -trip->index) {
+ parent_ptr = &lookup;
+ break;
+ }
+ ok = gtk_tree_model_iter_next(model, &lookup);
+ }
}
/* store dive */