diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-01-24 07:05:32 +1200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-24 07:07:02 +1200 |
commit | c3614424f9117c053c783fba5f6499743ec125f9 (patch) | |
tree | a598bd77a071d74e3c9570adbe4e39f544f996c9 /profile.c | |
parent | 6aee901f6fb329b3c8b3945fc394842a921ca2c7 (diff) | |
download | subsurface-c3614424f9117c053c783fba5f6499743ec125f9.tar.gz |
Correcly look at all relevant dive computer structures
When calculating maxima for a dive, we need to take data from all existing
dive computer structures plus potentially also a fake dive computer
structure that is just passed in in order to create a meaningful profile.
Commit 86c961614bfa ("Actually walk all dive computers, don't just claim
to do so") missed that second case and no longer took the fake_dc into
account, breaking the display of dives that don't have samples.
Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -442,9 +442,10 @@ static void check_setpoint_events(struct dive *dive, struct divecomputer *dc, st } -struct plot_info calculate_max_limits_new(struct dive *dive) +struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *given_dc) { struct divecomputer *dc = &(dive->dc); + bool seen = false; static struct plot_info pi; int maxdepth = dive->maxdepth.mm; int maxtime = 0; @@ -465,6 +466,8 @@ struct plot_info calculate_max_limits_new(struct dive *dive) /* Then do all the samples from all the dive computers */ do { + if (dc == given_dc) + seen = true; int i = dc->samples; int lastdepth = 0; struct sample *s = dc->sample; @@ -497,7 +500,12 @@ struct plot_info calculate_max_limits_new(struct dive *dive) lastdepth = depth; s++; } - } while ((dc = dc->next) != NULL); + dc = dc->next; + if (dc == NULL && !seen) { + dc = given_dc; + seen = true; + } + } while (dc != NULL); if (minpressure > maxpressure) minpressure = 0; |