1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00

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

View File

@ -152,9 +152,23 @@ namespace osu.Game.Skinning
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo)) if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
return null; 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 return new SkinnableTargetComponentsContainer
{ {
ChildrenEnumerable = skinnableInfo.Select(i => i.CreateInstance()) Children = components,
}; };
} }