summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-11-26 15:12:19 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-26 21:45:38 -0700
commitdf3671390d4b009525faf00926ca2a7b558a8ae6 (patch)
tree97ba42aeff89f29fa148f7f3d38f9a8860916695
parent6fe52ee19e5e9cd33bd1ceab4609f31829ff2f08 (diff)
downloadsubsurface-df3671390d4b009525faf00926ca2a7b558a8ae6.tar.gz
Fix dive computer event handling if there are no samples
This actually triggers for one of our insane test dives (test15): it has no samples, so we created a fake dive computer entry with the a fake profile in it, but we didn't copy the events over. Having a dive with no samples, yet having events from the dive computer, sounds pretty bogus. But that test-case did show that when that bogus situation happens, we had two independent buglets: (a) we didn't insert the entries in the fake dive computer entry we used and (b) we would then mix up the events of the fake dive computer entry with the first dive computer of a dive. Fix this, just to make test15 happy again. And eventually, when we actually plot the information for multiple dive computers, fixing case (b) would become necessary even for real dives. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--profile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/profile.c b/profile.c
index bbc8c5361..a385d6825 100644
--- a/profile.c
+++ b/profile.c
@@ -1703,7 +1703,7 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer
pi->nr = nr;
pi_idx = 2; /* the two extra events at the start */
/* check for gas changes before the samples start */
- ev = get_next_event(dive->dc.events, "gaschange");
+ ev = get_next_event(dc->events, "gaschange");
while (ev && ev->time.seconds < dc->sample->time.seconds) {
entry = pi->entry + pi_idx;
entry->sec = ev->time.seconds;
@@ -1716,7 +1716,7 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer
ev = get_next_event(ev->next, "gaschange");
}
/* find the first deco/ceiling event (if any) */
- ceil_ev = get_next_event(dive->dc.events, "ceiling");
+ ceil_ev = get_next_event(dc->events, "ceiling");
sec = 0;
lastindex = 0;
lastdepth = -1;
@@ -1958,6 +1958,7 @@ void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale)
fake[2].time.seconds = duration - asc_desc_time;
fake[2].depth.mm = maxdepth;
fake[3].time.seconds = duration * 1.00;
+ fakedc.events = dc->events;
dc = &fakedc;
}