(74c45abbe) Fixed: GUIDropdown parent returning a null GUIComponent when opening CharacterEditor & promptly crashing after

This commit is contained in:
Joonas Rikkonen
2019-06-11 21:48:10 +03:00
parent ae145b8044
commit d8e7c79a21
4 changed files with 10 additions and 14 deletions
@@ -148,7 +148,14 @@ namespace Barotrauma
//find the parent GUIListBox highest in the hierarchy
for (int i = parentHierarchy.Count - 1; i >= 0; i--)
{
if (parentHierarchy[i].GUIComponent is GUIListBox) return parentHierarchy[i]?.Parent ?? parentHierarchy[i];
if (parentHierarchy[i].GUIComponent is GUIListBox)
{
if (parentHierarchy[i].Parent != null && parentHierarchy[i].Parent.GUIComponent != null)
{
return parentHierarchy[i].Parent;
}
return parentHierarchy[i];
}
}
//or just go with the direct parent if there are no listboxes in the hierarchy
parentHierarchy.Clear();