mirror of
https://github.com/ppy/osu
synced 2025-01-20 21:10:49 +00:00
Merge pull request #8206 from peppy/fix-cross-thread-operation
Fix download failures potentially crashing game
This commit is contained in:
commit
34629fe974
@ -15,11 +15,13 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when a <typeparamref name="TModel"/> download begins.
|
/// Fired when a <typeparamref name="TModel"/> download begins.
|
||||||
|
/// This is NOT run on the update thread and should be scheduled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
|
event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when a <typeparamref name="TModel"/> download is interrupted, either due to user cancellation or failure.
|
/// Fired when a <typeparamref name="TModel"/> download is interrupted, either due to user cancellation or failure.
|
||||||
|
/// This is NOT run on the update thread and should be scheduled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Action<ArchiveDownloadRequest<TModel>> DownloadFailed;
|
event Action<ArchiveDownloadRequest<TModel>> DownloadFailed;
|
||||||
|
|
||||||
|
@ -53,17 +53,17 @@ namespace osu.Game.Online
|
|||||||
manager.ItemRemoved += itemRemoved;
|
manager.ItemRemoved += itemRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadBegan(ArchiveDownloadRequest<TModel> request)
|
private void downloadBegan(ArchiveDownloadRequest<TModel> request) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (request.Model.Equals(Model.Value))
|
if (request.Model.Equals(Model.Value))
|
||||||
attachDownload(request);
|
attachDownload(request);
|
||||||
}
|
});
|
||||||
|
|
||||||
private void downloadFailed(ArchiveDownloadRequest<TModel> request)
|
private void downloadFailed(ArchiveDownloadRequest<TModel> request) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (request.Model.Equals(Model.Value))
|
if (request.Model.Equals(Model.Value))
|
||||||
attachDownload(null);
|
attachDownload(null);
|
||||||
}
|
});
|
||||||
|
|
||||||
private ArchiveDownloadRequest<TModel> attachedRequest;
|
private ArchiveDownloadRequest<TModel> attachedRequest;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user