From 0b8b3004172cbec96f2def99a1278a2022051b05 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 12:59:57 +0000 Subject: [PATCH] Fix #11649: Allow disabling a widget that does not exist. Orders window has different widget layouts dependening on vehicle type which don't all have the same widgets, and therefore it tries to disable widgets that might not exist. Restore the old behaviour of ignoring such requests, instead of crashing. --- src/window_gui.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/window_gui.h b/src/window_gui.h index 69ecaf068a..49426c5000 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -327,7 +327,8 @@ public: */ inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat) { - this->GetWidget(widget_index)->SetDisabled(disab_stat); + NWidgetCore *nwid = this->GetWidget(widget_index); + if (nwid != nullptr) nwid->SetDisabled(disab_stat); } /**