From a92ee1e05dc1c0f6a39673cf2d595d63edf35061 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Fri, 3 Feb 2023 19:09:54 +1300 Subject: [PATCH] Refactoring: Use core functions to find gasmixes in TankItem. Small refactoring to use `get_gasmix_at_time` from `core` in `TankItem` to find the first gasmix used during a dive. Signed-off-by: Michael Keller --- profile-widget/tankitem.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/profile-widget/tankitem.cpp b/profile-widget/tankitem.cpp index 3079c10dd..1955ef52e 100644 --- a/profile-widget/tankitem.cpp +++ b/profile-widget/tankitem.cpp @@ -79,16 +79,10 @@ void TankItem::setData(const struct dive *d, const struct divecomputer *dc, int if (d->cylinders.nr <= 0) return; - // start with the first gasmix and at the start of the dive - int cyl = explicit_first_cylinder(d, dc); - struct gasmix gasmix = get_cylinder(d, cyl)->gasmix; - - // 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) { - gasmix = get_gasmix_from_event(d, ev); - ev = get_next_event(ev->next, "gaschange"); - } + // start with the first gasmix and at the start of the plotted range + const struct event *ev = NULL; + struct gasmix gasmix = gasmix_air; + gasmix = get_gasmix(d, dc, plotStartTime, &ev, gasmix); // work through all the gas changes and add the rectangle for each gas while it was used int startTime = plotStartTime;