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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-11-17 10:26:43 +01:00 committed by Dirk Hohndel
parent 911edfca71
commit 0fc58f4534

View file

@ -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;