X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=statistics.c;h=3a260066a259d58c2305ace1255f88e7f829e66f;hb=822b6409d752133090df24f5ca38f69656ff82b7;hp=19105653c2aa1ad8014cfa095dd86bf524f940fc;hpb=4033625567eafbb2c3c69da9189a0b0c87b74abc;p=ext%2Fsubsurface.git diff --git a/statistics.c b/statistics.c index 1910565..3a26006 100644 --- a/statistics.c +++ b/statistics.c @@ -142,25 +142,39 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) } } -void process_selected_dives(GList *selected_dives, GtkTreeModel *model) +/* make sure we skip the selected summary entries */ +void process_selected_dives(GList *selected_dives, int *selectiontracker, GtkTreeModel *model) { struct dive *dp; - unsigned int i; + unsigned int i, j; + int idx; GtkTreeIter iter; GtkTreePath *path; memset(&stats_selection, 0, sizeof(stats_selection)); - stats_selection.selection_size = amount_selected; - for (i = 0; i < amount_selected; ++i) { + /* adjust amount_selected and remove negative index entries from list */ + for (i = 0, j = 0; j < amount_selected; ++i) { GValue value = {0, }; path = g_list_nth_data(selected_dives, i); if (gtk_tree_model_get_iter(model, &iter, path)) { gtk_tree_model_get_value(model, &iter, 0, &value); - dp = get_dive(g_value_get_int(&value)); + idx = g_value_get_int(&value); + if (idx > 0) { + dp = get_dive(idx); + if (dp) { + selectiontracker[j] = idx; + process_dive(dp, &stats_selection); + j++; + continue; + } + } } - process_dive(dp, &stats_selection); + /* we didn't process it, so shorten the list */ + amount_selected--; } + /* record the actual number of dives selected */ + stats_selection.selection_size = amount_selected; } static void set_label(GtkWidget *w, const char *fmt, ...)