From f3b4d2a384e9c8ef6bbaa877bb83514566d3ad79 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 13:29:31 +0000 Subject: [PATCH] Fix #11649: Ignore disabling a widget that does not exist. (#11652) Orders window has different widget layouts depending 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); } /**