profile: fix tankbar

The logic has just been completely broken when implementing
zooming.

Fixes #3376

Reported-by: Anton Lundin glance@acc.umu.se

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-01-12 22:07:48 +01:00 committed by Dirk Hohndel
parent b56eacbaec
commit ab830fcfd7

View file

@ -89,19 +89,18 @@ void TankItem::setData(const struct dive *d, int plotStartTime, int plotEndTime)
// skip over all gas changes before the plotted range
const struct event *ev = get_next_event(dc->events, "gaschange");
while (ev && (int)ev->time.seconds <= plotStartTime)
while (ev && (int)ev->time.seconds <= plotStartTime) {
gasmix = get_gasmix_from_event(d, ev);
ev = get_next_event(ev->next, "gaschange");
}
// work through all the gas changes and add the rectangle for each gas while it was used
int startTime = plotStartTime;
while (ev && (int)ev->time.seconds < plotEndTime) {
gasmix = get_gasmix_from_event(d, ev);
createBar(startTime, ev->time.seconds, gasmix);
startTime = ev->time.seconds;
gasmix = get_gasmix_from_event(d, ev);
ev = get_next_event(ev->next, "gaschange");
}
if (ev)
gasmix = get_gasmix_from_event(d, ev);
createBar(startTime, plotEndTime, gasmix);
}