Merge pull request #17448 from peppy/fix-skin-component-crash-on-instantiation-failure

Avoid crashing if a skin component cannot be instantiated correctly
This commit is contained in:
Dan Balasescu 2022-03-25 19:41:52 +09:00 committed by GitHub
commit 6c172bac3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -152,9 +152,23 @@ public void UpdateDrawableTarget(ISkinnableTarget targetContainer)
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,
};
}