From a5f1f9830bfc0c13d3db751d65ea39bbba1e29e0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Feb 2019 16:21:01 +0900 Subject: [PATCH] Fix potential schedule race case and regression in enum setting --- .../Direct/DownloadTrackingComposite.cs | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs b/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs index f7d9264af0..d9eb827834 100644 --- a/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs +++ b/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs @@ -11,6 +11,9 @@ using osu.Game.Online.API.Requests; namespace osu.Game.Overlays.Direct { + /// + /// A component which tracks a beatmap through potential download/import/deletion. + /// public abstract class DownloadTrackingComposite : CompositeDrawable { public readonly Bindable BeatmapSet = new Bindable(); @@ -106,31 +109,22 @@ namespace osu.Game.Overlays.Direct } } - private void onRequestSuccess(string data) - { - Schedule(() => State.Value = DownloadState.Downloaded); - } + private void onRequestSuccess(string _) => Schedule(() => State.Value = DownloadState.Downloaded); - private void onRequestProgress(float progress) - { - Schedule(() => Progress.Value = progress); - } + private void onRequestProgress(float progress) => Schedule(() => Progress.Value = progress); - private void onRequestFailure(Exception e) - { - Schedule(() => attachDownload(null)); - } + private void onRequestFailure(Exception e) => Schedule(() => attachDownload(null)); - private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => setDownloadState(s, DownloadState.Downloaded); + private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => setDownloadStateFromManager(s, DownloadState.LocallyAvailable); - private void setRemoved(BeatmapSetInfo s) => setDownloadState(s, DownloadState.NotDownloaded); + private void setRemoved(BeatmapSetInfo s) => setDownloadStateFromManager(s, DownloadState.NotDownloaded); - private void setDownloadState(BeatmapSetInfo s, DownloadState state) + private void setDownloadStateFromManager(BeatmapSetInfo s, DownloadState state) => Schedule(() => { if (s.OnlineBeatmapSetID != BeatmapSet.Value?.OnlineBeatmapSetID) return; - Schedule(() => State.Value = state); - } + State.Value = state; + }); } }