Avoid crashing if a skin component cannot be instantiated correctly

This commit is contained in:
Dean Herbert 2022-03-25 18:31:23 +09:00
parent 4d91f403d8
commit a0a3bba46e
1 changed files with 15 additions and 1 deletions

View File

@ -144,9 +144,23 @@ public virtual Drawable GetDrawableComponent(ISkinComponent component)
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
return null;
var components = new List<Drawable>();
foreach (var i in skinnableInfo)
{
try
{
components.Add(i.CreateInstance());
}
catch (Exception e)
{
Logger.Error(e, $"Unable to create skin component {i.Type.Name}");
}
}
return new SkinnableTargetComponentsContainer
{
ChildrenEnumerable = skinnableInfo.Select(i => i.CreateInstance())
Children = components,
};
}