summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--core/profile.c26
2 files changed, 17 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fb4c4cfd1..2e3fd0aad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+Desktop: fix profile display of planned dives with surface segments
maps: show the dive site as marker when opening Google Maps
Mobile: fix false rejection of Subsurface cloud SSL certificate
Mobile: fix misdetection of Shearwater Petrel 2 on iOS
diff --git a/core/profile.c b/core/profile.c
index efcfe45a4..6723f3734 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -391,6 +391,7 @@ static void calculate_max_limits_new(struct dive *dive, struct divecomputer *giv
{
struct divecomputer *dc = &(dive->dc);
bool seen = false;
+ bool found_sample_beyond_last_event = false;
int maxdepth = dive->maxdepth.mm;
int maxtime = 0;
int maxpressure = 0, minpressure = INT_MAX;
@@ -418,6 +419,14 @@ static void calculate_max_limits_new(struct dive *dive, struct divecomputer *giv
struct sample *s = dc->sample;
struct event *ev;
+ /* Make sure we can fit all events */
+ ev = dc->events;
+ while (ev) {
+ if (ev->time.seconds > maxtime)
+ maxtime = ev->time.seconds;
+ ev = ev->next;
+ }
+
while (--i >= 0) {
int depth = s->depth.mm;
int pressure = s->pressure[0].mbar;
@@ -440,21 +449,18 @@ static void calculate_max_limits_new(struct dive *dive, struct divecomputer *giv
if (depth > maxdepth)
maxdepth = s->depth.mm;
- if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD || in_planner()) &&
- s->time.seconds > maxtime)
+ /* Make sure that we get the first sample beyond the last event.
+ * If maxtime is somewhere in the middle of the last segment,
+ * populate_plot_entries() gets confused leading to display artifacts. */
+ if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD || in_planner() || !found_sample_beyond_last_event) &&
+ s->time.seconds > maxtime) {
+ found_sample_beyond_last_event = true;
maxtime = s->time.seconds;
+ }
lastdepth = depth;
s++;
}
- /* Make sure we can fit all events */
- ev = dc->events;
- while (ev) {
- if (ev->time.seconds > maxtime)
- maxtime = ev->time.seconds;
- ev = ev->next;
- }
-
dc = dc->next;
if (dc == NULL && !seen) {
dc = given_dc;