Changeset - r28355:6fb226bd4d6d
[Not reviewed]
master
0 1 0
Peter Nelson - 11 months ago 2023-12-30 13:29:31
peter1138@openttd.org
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.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/window_gui.h
Show inline comments
 
@@ -324,13 +324,14 @@ public:
 
	 * On certain conditions, they have to be disabled.
 
	 * @param widget_index index of this widget in the window
 
	 * @param disab_stat status to use ie: disabled = true, enabled = false
 
	 */
 
	inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
 
	{
 
		this->GetWidget<NWidgetCore>(widget_index)->SetDisabled(disab_stat);
 
		NWidgetCore *nwid = this->GetWidget<NWidgetCore>(widget_index);
 
		if (nwid != nullptr) nwid->SetDisabled(disab_stat);
 
	}
 

	
 
	/**
 
	 * Sets a widget to disabled.
 
	 * @param widget_index index of this widget in the window
 
	 */
0 comments (0 inline, 0 general)