mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-03 15:43:09 +00:00
Correcly look at all relevant dive computer structures
When calculating maxima for a dive, we need to take data from all existing
dive computer structures plus potentially also a fake dive computer
structure that is just passed in in order to create a meaningful profile.
Commit 86c961614b
("Actually walk all dive computers, don't just claim
to do so") missed that second case and no longer took the fake_dc into
account, breaking the display of dives that don't have samples.
Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6aee901f6f
commit
c3614424f9
3 changed files with 12 additions and 4 deletions
12
profile.c
12
profile.c
|
@ -442,9 +442,10 @@ static void check_setpoint_events(struct dive *dive, struct divecomputer *dc, st
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct plot_info calculate_max_limits_new(struct dive *dive)
|
struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *given_dc)
|
||||||
{
|
{
|
||||||
struct divecomputer *dc = &(dive->dc);
|
struct divecomputer *dc = &(dive->dc);
|
||||||
|
bool seen = false;
|
||||||
static struct plot_info pi;
|
static struct plot_info pi;
|
||||||
int maxdepth = dive->maxdepth.mm;
|
int maxdepth = dive->maxdepth.mm;
|
||||||
int maxtime = 0;
|
int maxtime = 0;
|
||||||
|
@ -465,6 +466,8 @@ struct plot_info calculate_max_limits_new(struct dive *dive)
|
||||||
|
|
||||||
/* Then do all the samples from all the dive computers */
|
/* Then do all the samples from all the dive computers */
|
||||||
do {
|
do {
|
||||||
|
if (dc == given_dc)
|
||||||
|
seen = true;
|
||||||
int i = dc->samples;
|
int i = dc->samples;
|
||||||
int lastdepth = 0;
|
int lastdepth = 0;
|
||||||
struct sample *s = dc->sample;
|
struct sample *s = dc->sample;
|
||||||
|
@ -497,7 +500,12 @@ struct plot_info calculate_max_limits_new(struct dive *dive)
|
||||||
lastdepth = depth;
|
lastdepth = depth;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
} while ((dc = dc->next) != NULL);
|
dc = dc->next;
|
||||||
|
if (dc == NULL && !seen) {
|
||||||
|
dc = given_dc;
|
||||||
|
seen = true;
|
||||||
|
}
|
||||||
|
} while (dc != NULL);
|
||||||
|
|
||||||
if (minpressure > maxpressure)
|
if (minpressure > maxpressure)
|
||||||
minpressure = 0;
|
minpressure = 0;
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct ev_select {
|
||||||
bool plot_ev;
|
bool plot_ev;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct plot_info calculate_max_limits_new(struct dive *dive);
|
struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *given_dc);
|
||||||
void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int bufsize, int sum);
|
void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int bufsize, int sum);
|
||||||
struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *dc, struct plot_info *pi);
|
struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *dc, struct plot_info *pi);
|
||||||
struct plot_info *analyze_plot_info(struct plot_info *pi);
|
struct plot_info *analyze_plot_info(struct plot_info *pi);
|
||||||
|
|
|
@ -535,7 +535,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
* so I'll *not* calculate everything if something is not being
|
* so I'll *not* calculate everything if something is not being
|
||||||
* shown.
|
* shown.
|
||||||
*/
|
*/
|
||||||
plotInfo = calculate_max_limits_new(&displayed_dive);
|
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
|
||||||
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth);
|
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth);
|
||||||
if (shouldCalculateMaxTime)
|
if (shouldCalculateMaxTime)
|
||||||
maxtime = get_maxtime(&plotInfo);
|
maxtime = get_maxtime(&plotInfo);
|
||||||
|
|
Loading…
Reference in a new issue