From c042a6de9ca067870b7d2b209971b462fe34705f Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 9 May 2016 23:41:04 +0100 Subject: [PATCH] Fix disable state of buttons in timetable window. Fixes crash when using buttons which should be disabled. --- src/timetable_gui.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 5128ac7876..49a18aff61 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -315,21 +315,17 @@ struct TimetableWindow : Window { } bool disable_speed = disable || selected % 2 != 1 || v->type == VEH_AIRCRAFT; - this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, disable); - this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable); + this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, disable || HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); + this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable || HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); this->SetWidgetDisabledState(WID_VT_CHANGE_SPEED, disable_speed); this->SetWidgetDisabledState(WID_VT_CLEAR_SPEED, disable_speed); this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !v->IsOrderListShared()); - this->SetWidgetDisabledState(WID_VT_START_DATE, v->orders.list == NULL); + this->SetWidgetDisabledState(WID_VT_START_DATE, v->orders.list == NULL || HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)); this->SetWidgetDisabledState(WID_VT_RESET_LATENESS, v->orders.list == NULL); - this->SetWidgetDisabledState(WID_VT_AUTOFILL, v->orders.list == NULL); + this->SetWidgetDisabledState(WID_VT_AUTOFILL, v->orders.list == NULL || HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); this->EnableWidget(WID_VT_AUTOMATE); this->EnableWidget(WID_VT_AUTO_SEPARATION); - this->SetWidgetDisabledState(WID_VT_START_DATE, HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)); - this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); - this->SetWidgetDisabledState(WID_VT_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); - this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); } else { this->DisableWidget(WID_VT_START_DATE); this->DisableWidget(WID_VT_CHANGE_TIME);