Fixed crash when setting a filter while the game is refreshing the server list

This commit is contained in:
juanjp600
2017-12-03 20:33:20 -03:00
parent f8e5a4f7ab
commit 4a1eea8c30
3 changed files with 25 additions and 48 deletions

View File

@@ -28,19 +28,11 @@ namespace Barotrauma
if (!Visible) return;
if (ComponentsToUpdate.Contains(this)) return;
ComponentsToUpdate.Add(this);
try
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
foreach (GUIComponent c in fixedChildren)
{
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
foreach (GUIComponent c in fixedChildren)
{
c.AddToGUIUpdateList();
}
}
catch (Exception e)
{
DebugConsole.NewMessage("Error in AddToGUIUPdateList! GUIComponent runtime type: "+this.GetType().ToString()+"; children count: "+children.Count.ToString(),Color.Red);
throw;
c.AddToGUIUpdateList();
}
}
@@ -437,22 +429,14 @@ namespace Barotrauma
}
}*/
try
//use a fixed list since children can change their order in the main children list
//TODO: maybe find a more efficient way of handling changes in list order
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
foreach (GUIComponent c in fixedChildren)
{
//use a fixed list since children can change their order in the main children list
//TODO: maybe find a more efficient way of handling changes in list order
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
foreach (GUIComponent c in fixedChildren)
{
if (!c.Visible) continue;
c.Update(deltaTime);
}
}
catch (Exception e)
{
DebugConsole.NewMessage("Error in Update! GUIComponent runtime type: " + this.GetType().ToString() + "; children count: " + children.Count.ToString(), Color.Red);
throw;
if (!c.Visible) continue;
c.Update(deltaTime);
}
}

View File

@@ -259,29 +259,21 @@ namespace Barotrauma
if (!Visible) return;
if (ComponentsToUpdate.Contains(this)) return;
ComponentsToUpdate.Add(this);
try
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
int lastVisible = 0;
for (int i = 0; i < fixedChildren.Count; i++)
{
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
int lastVisible = 0;
for (int i = 0; i < fixedChildren.Count; i++)
if (fixedChildren[i] == frame) continue;
if (!IsChildVisible(fixedChildren[i]))
{
if (fixedChildren[i] == frame) continue;
if (!IsChildVisible(fixedChildren[i]))
{
if (lastVisible > 0) break;
continue;
}
lastVisible = i;
fixedChildren[i].AddToGUIUpdateList();
if (lastVisible > 0) break;
continue;
}
}
catch (Exception e)
{
DebugConsole.NewMessage("Error in AddToGUIUpdateList! GUIComponent runtime type: " + this.GetType().ToString() + "; children count: " + children.Count.ToString(), Color.Red);
throw;
lastVisible = i;
fixedChildren[i].AddToGUIUpdateList();
}
if (scrollBarEnabled && !scrollBarHidden) scrollBar.AddToGUIUpdateList();

View File

@@ -124,9 +124,10 @@ namespace Barotrauma
private void FilterServers()
{
serverList.RemoveChild(serverList.FindChild("noresults"));
foreach (GUIComponent child in serverList.children)
{
if (!(child.UserData is ServerInfo)) continue;
ServerInfo serverInfo = (ServerInfo)child.UserData;
child.Visible =