mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't allow to plan dives out of order
The planned dive always has to be the last dive in the dive list. To make sure of that we interpret the relative start time to be relative to either the current time or the end of the last dive, whichever is later. This fixes a bug where we would delete the wrong dive and get our data structures confused by planning multiple dives out of order. Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
de7d5b2d5b
commit
aa55bda944
1 changed files with 9 additions and 2 deletions
11
planner.c
11
planner.c
|
@ -1053,8 +1053,15 @@ static gboolean starttime_focus_out_cb(GtkWidget *entry, GdkEvent * event, gpoin
|
|||
|
||||
starttimetext = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
if (validate_time(starttimetext, &starttime, &is_rel)) {
|
||||
/* we alway make this relative for now */
|
||||
diveplan.when = current_time_notz() + starttime;
|
||||
/* 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 (last_dive && last_dive->when + last_dive->dc.duration.seconds > cur)
|
||||
cur = last_dive->when + last_dive->dc.duration.seconds;
|
||||
}
|
||||
diveplan.when = cur + starttime;
|
||||
show_planned_dive();
|
||||
} else {
|
||||
/* we need to instead change the color of the input field or something */
|
||||
|
|
Loading…
Add table
Reference in a new issue