Merge pull request #10061 from peppy/fix-ruleset-settings-crash

Fix potential hard crash if ruleset settings fail to construct
This commit is contained in:
Dan Balasescu
2020-09-04 17:07:55 +09:00
committed by GitHub

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
{ {
@ -33,11 +35,19 @@ namespace osu.Game.Overlays.Settings.Sections
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {
foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance())) foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance()))
{
try
{ {
SettingsSubsection section = ruleset.CreateSettings(); SettingsSubsection section = ruleset.CreateSettings();
if (section != null) if (section != null)
Add(section); Add(section);
} }
catch (Exception e)
{
Logger.Error(e, "Failed to load ruleset settings");
}
}
} }
} }
} }