Fix the progress events when no dives are present

When no dives are present, the maximum value for the progress events is
set to zero, which triggers an assert. Fixed by letting the progress
events reach 100% instead.
This commit is contained in:
Jef Driesen 2022-12-03 13:17:04 +01:00
parent ed0b21beae
commit 59a0844ee6

View File

@ -313,7 +313,8 @@ deepsix_excursion_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
unsigned int ndives = array_uint16_le (rsp_index);
// Update and emit a progress event.
progress.maximum = ndives * NSTEPS;
progress.current = 1 * NSTEPS;
progress.maximum = (ndives + 1) * NSTEPS;
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
dc_buffer_t *buffer = dc_buffer_new(0);
@ -341,7 +342,7 @@ deepsix_excursion_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
unsigned int length = array_uint32_le (rsp_header + 8);
// Update and emit a progress event.
progress.current = i * NSTEPS + STEP(sizeof(rsp_header), sizeof(rsp_header) + length);
progress.current = (i + 1) * NSTEPS + STEP(sizeof(rsp_header), sizeof(rsp_header) + length);
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
dc_buffer_clear(buffer);
@ -377,7 +378,7 @@ deepsix_excursion_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
}
// Update and emit a progress event.
progress.current = i * NSTEPS + STEP(sizeof(rsp_header) + offset + n, sizeof(rsp_header) + length);
progress.current = (i + 1) * NSTEPS + STEP(sizeof(rsp_header) + offset + n, sizeof(rsp_header) + length);
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
if (!dc_buffer_append(buffer, rsp_profile, n)) {