From df3671390d4b009525faf00926ca2a7b558a8ae6 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 26 Nov 2012 15:12:19 -0800 Subject: 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 Signed-off-by: Dirk Hohndel --- profile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'profile.c') 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; } -- cgit v1.2.3-70-g09d2