diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-28 11:49:03 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-28 21:50:25 -0700 |
commit | 92b1c318bda8a3a5fb552592af82bf95d9d0bf7b (patch) | |
tree | 2d2201b6ebf5020ab163ecd9477c8d3814f142be /core/profile.c | |
parent | df1bd0015a2f69429116c29d6e7818a33a9070b0 (diff) | |
download | subsurface-92b1c318bda8a3a5fb552592af82bf95d9d0bf7b.tar.gz |
Fix manual pressures for cylinders with no gas switches
"If it hasn't been tested, it doesn't work".
All my testing of the multiple sensor pressures have been with some
reasonably "interesting" dives: they actually *have* sensor pressures.
But that test coverage means that I missed the truly trivial case of
just having manual pressures for a single cylinder.
Because there's only a single cylinder, it doesn't have any cylinder
changes, and because there were no cylinder changes, it never filled in
the use range for that cylinder.
So then it never showed the pressure profile at all.
Duh.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/profile.c')
-rw-r--r-- | core/profile.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/core/profile.c b/core/profile.c index cb11251cf..e9a625d30 100644 --- a/core/profile.c +++ b/core/profile.c @@ -822,6 +822,10 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc unsigned int first[MAX_CYLINDERS] = { 0, }; unsigned int last[MAX_CYLINDERS] = { 0, }; struct divecomputer *secondary; + int endtime = dc->samples ? dc->sample[dc->samples-1].time.seconds : dive->duration.seconds; + + for (i = 0; i < MAX_CYLINDERS; i++) + last[i] = endtime; for (ev = get_next_event(dc->events, "gaschange"); ev != NULL; ev = get_next_event(ev->next, "gaschange")) { int cyl = ev->gas.index; @@ -836,27 +840,22 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc last[cyl] = sec; if (!seen[cyl]) { - int endtime = sec; - if (dc->samples) - endtime = dc->sample[dc->samples-1].time.seconds; - // The end time may be updated by a subsequent cylinder change first[cyl] = sec; - last[cyl] = endtime; seen[cyl] = 1; } } + if (prev >= 0) + last[prev] = endtime; for (i = 0; i < MAX_CYLINDERS; i++) { - if (seen[i]) { - cylinder_t *cyl = dive->cylinder + i; - int start = cyl->start.mbar; - int end = cyl->end.mbar; - - if (start) - add_plot_pressure(pi, first[i], i, start); - if (end) - add_plot_pressure(pi, last[i], i, end); + cylinder_t *cyl = dive->cylinder + i; + int start = cyl->start.mbar; + int end = cyl->end.mbar; + + if (start && end) { + add_plot_pressure(pi, first[i], i, start); + add_plot_pressure(pi, last[i], i, end); } } |