Fix profile display for dives with no samples

For dives with no samples, we crate a fake dive computer with a set of
made-up samples and use those to display the profile.

However, the actual calculations to do the maximum duration and depth
etc were always done with the "real" dive information, which is empty.
As a result, the scale of the plot ended up being bogus, and part of
the dive would be missing.

Trivially fix by just passing the same dive computer information to
calculate_max_limits() that we use for everything else.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2013-01-04 14:18:35 -08:00 committed by Dirk Hohndel
parent cca847791a
commit 635f190302

View file

@ -1474,9 +1474,8 @@ static int count_gas_change_events(struct divecomputer *dc)
return count;
}
static void calculate_max_limits(struct dive *dive, struct graphics_context *gc)
static void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc)
{
struct divecomputer *dc;
struct plot_info *pi;
int maxdepth = 0;
int maxtime = 0;
@ -1500,7 +1499,6 @@ static void calculate_max_limits(struct dive *dive, struct graphics_context *gc)
}
/* Then do all the samples from all the dive computers */
dc = &dive->dc;
do {
int i = dc->samples;
int lastdepth = 0;
@ -1908,7 +1906,7 @@ void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale)
* Set up limits that are independent of
* the dive computer
*/
calculate_max_limits(dive, gc);
calculate_max_limits(dive, dc, gc);
/* shift the drawing area so we have a nice margin around it */
cairo_translate(gc->cr, drawing_area->x, drawing_area->y);