1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 08:07:24 +08:00

Guard against potential exception while blocking realm

This commit is contained in:
Dean Herbert 2022-01-24 18:24:25 +09:00
parent 9ff9611296
commit b0919722ac

View File

@ -1,11 +1,13 @@
// 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 System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Localisation; using osu.Game.Localisation;
@ -52,7 +54,10 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
blockAction.Action = () => blockAction.Action = () =>
{ {
var blocking = realmFactory.BlockAllOperations(); try
{
var token = realmFactory.BlockAllOperations();
blockAction.Enabled.Value = false; blockAction.Enabled.Value = false;
// As a safety measure, unblock after 10 seconds. // As a safety measure, unblock after 10 seconds.
@ -68,8 +73,8 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
void unblock() void unblock()
{ {
blocking?.Dispose(); token?.Dispose();
blocking = null; token = null;
Scheduler.Add(() => Scheduler.Add(() =>
{ {
@ -77,6 +82,11 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
unblockAction.Action = null; unblockAction.Action = null;
}); });
} }
}
catch (Exception e)
{
Logger.Error(e, "Blocking realm failed");
}
}; };
} }
} }