summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-01-02 09:52:43 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-02 10:26:30 -0800
commitb900a211656bac71ef54ccec5361671e8fa5874c (patch)
tree84d93db4448f6b60577fb443ff8694e425eb48de
parent52f438bcd07754b2c4aae7d20359de9ac2092705 (diff)
downloadsubsurface-b900a211656bac71ef54ccec5361671e8fa5874c.tar.gz
Fix mixed dive/trip tree model grouping
In commit 96db56f89c76 ("Allow overlapping (and disjoint) dive trips") I allowed dives to be part of arbitrary dive trips regardless of date, which meant that the divelist tree model code needed to find the right parent for a dive as it was inserted. That code stupidly assumed that the top level of the dive list tree containted *only* trips, which is not at all the case. It happens to be true if you group all your dives into divetrips (the common case for autogroup=1, which real users do tend to have), but now that Dirk made the autogrouping be a per-xml-file setting, it became much easier to trigger the "mixed trips and non-trip dives" case, and that showed the stupid bug with the test dives. So instead of just blindly iterating to the 'n'th entry, search for the actual entry that is the dive trip we want to associate a dive with. Reported-by: Lubomir Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-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 */