From a0a3bba46e82f954c2264e9553a24c160d9fa813 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Mar 2022 18:31:23 +0900 Subject: [PATCH] Avoid crashing if a skin component cannot be instantiated correctly --- osu.Game/Skinning/Skin.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index e00dd950a7..7e93a74b7e 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -144,9 +144,23 @@ namespace osu.Game.Skinning if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo)) return null; + var components = new List(); + + 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, }; }