mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
6fe52ee19e
commit
df3671390d
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue