Some extra error checking in GUIComponent and PhysicsBody syncing logic

This commit is contained in:
Regalis
2017-03-03 20:29:07 +02:00
parent ee16f0708b
commit 4c863cfdd7
2 changed files with 41 additions and 4 deletions
+17
View File
@@ -461,6 +461,23 @@ namespace Barotrauma
public virtual void AddChild(GUIComponent child)
{
if (child == null) return;
if (child.IsParentOf(this))
{
DebugConsole.ThrowError("Tried to add the parent of a GUIComponent as a child.\n" + Environment.StackTrace);
return;
}
if (child == this)
{
DebugConsole.ThrowError("Tried to add a GUIComponent as its own child\n" + Environment.StackTrace);
return;
}
if (children.Contains(child))
{
DebugConsole.ThrowError("Tried to add a the same child twice to a GUIComponent" + Environment.StackTrace);
return;
}
child.parent = this;
child.UpdateDimensions(this);