summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h1
-rw-r--r--planner.c5
2 files changed, 4 insertions, 2 deletions
diff --git a/dive.h b/dive.h
index f6677ab2c..7e00a6ce6 100644
--- a/dive.h
+++ b/dive.h
@@ -647,6 +647,7 @@ struct divedatapoint {
struct diveplan {
timestamp_t when;
+ int lastdive_nr;
int surface_pressure; /* mbar */
int bottomsac; /* ml/min */
int decosac; /* ml/min */
diff --git a/planner.c b/planner.c
index b6c4d521c..d5a733e6e 100644
--- a/planner.c
+++ b/planner.c
@@ -1138,8 +1138,8 @@ static gboolean starttime_focus_out_cb(GtkWidget *entry, GdkEvent * event, gpoin
/* we alway make this relative - either from the current time or from the
* end of the last dive, whichever is later */
timestamp_t cur = current_time_notz();
- if (dive_table.nr) {
- struct dive *last_dive = get_dive(dive_table.nr - 1);
+ if (diveplan.lastdive_nr >= 0) {
+ struct dive *last_dive = get_dive(diveplan.lastdive_nr);
if (last_dive && last_dive->when + last_dive->dc.duration.seconds > cur)
cur = last_dive->when + last_dive->dc.duration.seconds;
}
@@ -1285,6 +1285,7 @@ void input_plan()
if (diveplan.dp)
free_dps(diveplan.dp);
memset(&diveplan, 0, sizeof(diveplan));
+ diveplan.lastdive_nr = dive_table.nr - 1;
free(cache_data);
cache_data = NULL;
planned_dive = NULL;