1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 04:53:12 +08:00

Fix potential schedule race case and regression in enum setting

This commit is contained in:
Dean Herbert 2019-02-14 16:21:01 +09:00
parent a289cb7c6a
commit a5f1f9830b

View File

@ -11,6 +11,9 @@ using osu.Game.Online.API.Requests;
namespace osu.Game.Overlays.Direct namespace osu.Game.Overlays.Direct
{ {
/// <summary>
/// A component which tracks a beatmap through potential download/import/deletion.
/// </summary>
public abstract class DownloadTrackingComposite : CompositeDrawable public abstract class DownloadTrackingComposite : CompositeDrawable
{ {
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>(); public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
@ -106,31 +109,22 @@ namespace osu.Game.Overlays.Direct
} }
} }
private void onRequestSuccess(string data) private void onRequestSuccess(string _) => Schedule(() => State.Value = DownloadState.Downloaded);
{
Schedule(() => State.Value = DownloadState.Downloaded);
}
private void onRequestProgress(float progress) private void onRequestProgress(float progress) => Schedule(() => Progress.Value = progress);
{
Schedule(() => Progress.Value = progress);
}
private void onRequestFailure(Exception e) private void onRequestFailure(Exception e) => Schedule(() => attachDownload(null));
{
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) if (s.OnlineBeatmapSetID != BeatmapSet.Value?.OnlineBeatmapSetID)
return; return;
Schedule(() => State.Value = state); State.Value = state;
} });
} }
} }