From e9e9996766a47044249cbcb7ff7185fb04ac9882 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Mar 2015 12:31:00 -0700 Subject: Better testing if the first gas is explicit Given that we might be adding a gas change event at t = 0 we need to check for both that and t = time_or_first_sample. Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveeventitem.cpp | 4 +++- statistics.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp index 700430007..0d81e7b45 100644 --- a/qt-ui/profile/diveeventitem.cpp +++ b/qt-ui/profile/diveeventitem.cpp @@ -135,7 +135,9 @@ bool DiveEventItem::shouldBeHidden() * Don't bother showing those */ struct sample *first_sample = &get_dive_dc(&displayed_dive, dc_number)->sample[0]; - if (!strcmp(event->name, "gaschange") && first_sample && event->time.seconds == first_sample->time.seconds) + if (!strcmp(event->name, "gaschange") && + (event->time.seconds == 0 || + (first_sample && event->time.seconds == first_sample->time.seconds))) return true; for (int i = 0; i < evn_used; i++) { diff --git a/statistics.c b/statistics.c index 17176f714..1b2a1a6d3 100644 --- a/statistics.c +++ b/statistics.c @@ -306,7 +306,8 @@ bool is_cylinder_used(struct dive *dive, int idx) for_each_dc(dive, dc) { struct event *event = get_next_event(dc->events, "gaschange"); while (event) { - if (dc->sample && event->time.seconds == dc->sample[0].time.seconds) + if (dc->sample && (event->time.seconds == 0 || + (dc->samples && dc->sample[0].time.seconds == event->time.seconds))) firstGasExplicit = true; if (get_cylinder_index(dive, event) == idx) return true; -- cgit v1.2.3-70-g09d2