Import: don't add to new trip while downloading

Since process_imported_dives() can add dives to a newly generated
trip, this need not be done in the downloading code. This makes
data flow distinctly simpler, as no trip table and no add-new-trip
flag has to be passed down to the libdivecomputer glue code.

Moreover, since now the trip creation is done at the import step
rather than the download step, the latest status of the "add to
new trip" checkbox will be considered.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-01-13 10:58:04 +02:00 committed by Dirk Hohndel
parent 1cd0863cca
commit ff9506b21b
12 changed files with 18 additions and 74 deletions

View file

@ -1661,8 +1661,10 @@ bool try_to_merge_trip(struct dive_trip *trip_import, struct dive_table *import_
* 3) Trips to be added
* The dives to be added are owning (i.e. the caller is responsible
* for freeing them).
* The dives and trips in import_table and import_trip table are
* The dives and trips in "import_table" and "import_trip_table" are
* consumed. On return, both tables have size 0.
* "import_trip_table" may be NULL if all dives are not associated
* with a trip.
* The output parameters should be empty - if not, their content
* will be cleared!
*
@ -1690,6 +1692,13 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
bool sequence_changed = false;
bool new_dive_has_number = false;
/* If the caller didn't pass an import_trip_table because all
* dives are tripless, provide a local table. This may be
* necessary if the trips are autogrouped */
struct trip_table local_trip_table = { 0 };
if (!import_trip_table)
import_trip_table = &local_trip_table;
/* Make sure that output parameters don't contain garbage */
clear_table(dives_to_add);
clear_table(dives_to_remove);