diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-25 20:06:54 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-26 09:30:27 -0800 |
commit | ffa3fd551c2571060b5f41b7dedad3e714e33311 (patch) | |
tree | daaeb39832dcff1721f741b5d85c0514ec705464 /gtk-gui.c | |
parent | 85f0749c854b014d6f8759426fa981eb9418ca18 (diff) | |
download | subsurface-ffa3fd551c2571060b5f41b7dedad3e714e33311.tar.gz |
Clarify (and fix) dive trip auto-generation
This makes the dive trip auto-generation a separate pass from the
showing of the dive trips, which makes things much more understandable.
It simplifies the code a lot too, because it's much more natural to
generate the automatic trip data by walking the dives from oldest to
newest (while the tree model wants to walk the other way).
It gets rid of the most annoying part of using the gtk tree model for
dive trip management, but some still remains.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 22 |
1 files changed, 2 insertions, 20 deletions
@@ -262,18 +262,8 @@ static gboolean ask_save_changes() return quit; } -static void dive_trip_unref(gpointer data, gpointer user_data) -{ - dive_trip_t *dive_trip = (dive_trip_t *)data; - if (dive_trip->location) - free(dive_trip->location); - free(data); -} - static void file_close(GtkWidget *w, gpointer data) { - int i; - if (unsaved_changes()) if (ask_save_changes() == FALSE) return; @@ -283,20 +273,12 @@ static void file_close(GtkWidget *w, gpointer data) existing_filename = NULL; /* free the dives and trips */ - for (i = 0; i < dive_table.nr; i++) - free(get_dive(i)); - dive_table.nr = 0; + while (dive_table.nr) + delete_single_dive(0); dive_table.preexisting = 0; mark_divelist_changed(FALSE); - /* inlined version of g_list_free_full(dive_trip_list, free); */ - g_list_foreach(dive_trip_list, (GFunc)dive_trip_unref, NULL); - g_list_free(dive_trip_list); - - dive_trip_list = NULL; - /* clear the selection and the statistics */ - amount_selected = 0; selected_dive = 0; process_selected_dives(); clear_stats_widgets(); |