From 0fc58f45345f9d33a896a284cba5420ed4f4b1bc Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 17 Nov 2018 10:26:43 +0100 Subject: [PATCH] Parser: add dive to trip at end of dive-parsing When adding the dive to its trip before having filled out "when", the dive gets added at the first position (when=0), which is usually not correct. Instead, add the dive to its trip when all fields are correctly filled out. Signed-off-by: Berthold Stoeger --- core/parse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/parse.c b/core/parse.c index f54d36742..6f12736a8 100644 --- a/core/parse.c +++ b/core/parse.c @@ -243,10 +243,6 @@ void dive_start(struct parser_state *state) state->cur_dive = alloc_dive(); reset_dc_info(&state->cur_dive->dc, state); memset(&state->cur_tm, 0, sizeof(state->cur_tm)); - if (state->cur_trip) { - add_dive_to_trip(state->cur_dive, state->cur_trip); - state->cur_dive->tripflag = IN_TRIP; - } state->o2pressure_sensor = 1; } @@ -258,6 +254,10 @@ void dive_end(struct parser_state *state) free_dive(state->cur_dive); else record_dive_to_table(state->cur_dive, state->target_table); + if (state->cur_trip) { + add_dive_to_trip(state->cur_dive, state->cur_trip); + state->cur_dive->tripflag = IN_TRIP; + } state->cur_dive = NULL; state->cur_dc = NULL; state->cur_location.lat.udeg = 0;