diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-11-23 15:18:59 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-01-09 20:58:04 -0800 |
commit | f8327ed51bc2298e2c7ef69a1ef0f82509e8d8d4 (patch) | |
tree | 932758970f9967a25d7958ad830cd0ab08594a00 /core/divelist.c | |
parent | 7923507e76e8d64c6c457664ec59f10c884a9fb0 (diff) | |
download | subsurface-f8327ed51bc2298e2c7ef69a1ef0f82509e8d8d4.tar.gz |
Core: move autogroup() into divelist.c
After loading or importing, the caller usually called autogroup()
to autogroup dives if so wished by the user. This has already led
to bugs, when autogroup() was forgotten.
Instead, call autogroup() directly in the process_loaded_dives()
and process_imported_dives() functions. Not only does this prevent
forgetting the call - it also means that autogrouping can be
changed without changing every caller.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divelist.c')
-rw-r--r-- | core/divelist.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/divelist.c b/core/divelist.c index 3ce2d4704..8934624c4 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -25,7 +25,6 @@ * dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive) * dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocated) * dive_trip_t *get_trip_for_new_dive(struct dive *new_dive, bool *allocated) - * void autogroup_dives(void) * void combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b) * dive_trip_t *combine_trips_create(struct dive_trip *trip_a, struct dive_trip *trip_b) * struct dive *unregister_dive(int idx) @@ -1042,7 +1041,7 @@ dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocat * Walk the dives from the oldest dive, and see if we can autogroup them. * But only do this when the user selected autogrouping. */ -void autogroup_dives(void) +static void autogroup_dives(void) { int from, to; dive_trip_t *trip; @@ -1354,6 +1353,9 @@ void process_loaded_dives() set_dc_nickname(dive); sort_table(&dive_table); + + /* Autogroup dives if desired by user. */ + autogroup_dives(); } /* @@ -1502,6 +1504,9 @@ void process_imported_dives(struct dive_table *import_table, bool prefer_importe if (!sequence_changed) try_to_renumber(preexisting); + /* Autogroup dives if desired by user. */ + autogroup_dives(); + /* We might have deleted the old selected dive. * Choose the newest dive as selected (if any) */ current_dive = dive_table.nr > 0 ? dive_table.dives[dive_table.nr - 1] : NULL; |