Fix potential hard crash if ruleset settings fail to construct

This commit is contained in:
Dean Herbert 2020-09-04 16:15:57 +09:00
parent 974bef5586
commit a15653c77c

View File

@ -1,12 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Overlays.Settings.Sections.Gameplay; using osu.Game.Overlays.Settings.Sections.Gameplay;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Logging;
namespace osu.Game.Overlays.Settings.Sections namespace osu.Game.Overlays.Settings.Sections
{ {
@ -35,8 +37,18 @@ namespace osu.Game.Overlays.Settings.Sections
foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance())) foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance()))
{ {
SettingsSubsection section = ruleset.CreateSettings(); SettingsSubsection section = ruleset.CreateSettings();
if (section != null) if (section != null)
Add(section); {
try
{
Add(section);
}
catch (Exception e)
{
Logger.Error(e, $"Failed to load ruleset settings");
}
}
} }
} }
} }