Fix #9545: Crash when all cargo types are disabled. (#11432)

This is not a very useful state, but it's nice to not crash.

Some parts of the game don't (yet) check for cargo types being redefined, that is out-of-scope here.

(cherry picked from commit bbd64bbe2b)
This commit is contained in:
Peter Nelson
2023-11-04 14:42:47 +00:00
committed by Jonathan G Rennison
parent 0b226865d5
commit 480e03360b
2 changed files with 5 additions and 3 deletions

View File

@@ -679,7 +679,8 @@ NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index)
spc->SetResize(0, 0);
col->Add(spc);
}
panel->Add(col);
/* If there are no cargo specs defined, then col won't have been created so don't add it. */
if (col != nullptr) panel->Add(col);
*biggest_index = WID_LGL_CARGO_LAST;
return panel;
}