News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Schedule editor can remain open when starting a convoy from depot

Started by victor_18993, Yesterday at 12:05:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

victor_18993

I found and fixed two related issues in the convoy schedule editor when starting a convoy from a depot.

If the Schedule tab was still open when pressing Start, the convoy could leave the depot while the editor remained open. Pending schedule changes could then be silently lost when that orphaned editor was later closed.

The orphaned editor also enabled a second, more serious issue: a late schedule-edit command could be processed after departure, leaving the convoy indefinitely in EDIT_SCHEDULE with no active editor left to clear that state.

The root cause was that several old destroy_win((ptrdiff_t)schedule) calls still referred to the former schedule_gui_t window identity. The current editor is the Schedule tab inside convoi_info_t, so those calls no longer closed the active editor.

The fix restores the intended lifecycle:

- when Start is pressed with an active schedule editor, the editor is closed first;
- closing it applies the pending schedule changes, matching the historical behaviour of the old schedule editor;
- the convoy is started only afterwards;
- depot_t::start_convoi() also contains the same safeguard for non-GUI start paths.

This removes the orphaned editor and structurally eliminates the EDIT_SCHEDULE freeze without adding a separate state-machine workaround.

Validation on trunk:

- 286/286 automated tests before and after
- 13/13 tested editing sessions applied exactly once
- 0 orphaned schedule editors
- 0 stale editing sessions
- 0 EDIT_SCHEDULE freezes
- starting without an open editor remains unchanged
- normal schedule editing remains unchanged
- no savegame, network protocol or checksum changes
- 4 files, +23/-15

The historical SVN implementation was also checked: closing the old schedule editor applied the schedule, so applying pending changes before Start restores the previous behaviour rather than introducing a new semantic.

The fix has now been integrated into the official trunk as:

r12174 — FIX: close convoy schedule editor before starting from depot
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)