diff options
-rw-r--r-- | dive.h | 1 | ||||
-rw-r--r-- | planner.c | 5 |
2 files changed, 4 insertions, 2 deletions
@@ -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 */ @@ -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; |