mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 14:12:56 +08:00
Fix memory leaks from download buttons (#5606)
Fix memory leaks from download buttons
This commit is contained in:
commit
bf0f6e1053
@ -48,22 +48,24 @@ namespace osu.Game.Online
|
|||||||
attachDownload(manager.GetExistingDownload(modelInfo.NewValue));
|
attachDownload(manager.GetExistingDownload(modelInfo.NewValue));
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
manager.DownloadBegan += download =>
|
manager.DownloadBegan += downloadBegan;
|
||||||
{
|
manager.DownloadFailed += downloadFailed;
|
||||||
if (download.Model.Equals(Model.Value))
|
|
||||||
attachDownload(download);
|
|
||||||
};
|
|
||||||
|
|
||||||
manager.DownloadFailed += download =>
|
|
||||||
{
|
|
||||||
if (download.Model.Equals(Model.Value))
|
|
||||||
attachDownload(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
manager.ItemAdded += itemAdded;
|
manager.ItemAdded += itemAdded;
|
||||||
manager.ItemRemoved += itemRemoved;
|
manager.ItemRemoved += itemRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void downloadBegan(ArchiveDownloadRequest<TModel> request)
|
||||||
|
{
|
||||||
|
if (request.Model.Equals(Model.Value))
|
||||||
|
attachDownload(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadFailed(ArchiveDownloadRequest<TModel> request)
|
||||||
|
{
|
||||||
|
if (request.Model.Equals(Model.Value))
|
||||||
|
attachDownload(null);
|
||||||
|
}
|
||||||
|
|
||||||
private ArchiveDownloadRequest<TModel> attachedRequest;
|
private ArchiveDownloadRequest<TModel> attachedRequest;
|
||||||
|
|
||||||
private void attachDownload(ArchiveDownloadRequest<TModel> request)
|
private void attachDownload(ArchiveDownloadRequest<TModel> request)
|
||||||
@ -126,8 +128,10 @@ namespace osu.Game.Online
|
|||||||
|
|
||||||
if (manager != null)
|
if (manager != null)
|
||||||
{
|
{
|
||||||
manager.DownloadBegan -= attachDownload;
|
manager.DownloadBegan -= downloadBegan;
|
||||||
|
manager.DownloadFailed -= downloadFailed;
|
||||||
manager.ItemAdded -= itemAdded;
|
manager.ItemAdded -= itemAdded;
|
||||||
|
manager.ItemRemoved -= itemRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
State.UnbindAll();
|
State.UnbindAll();
|
||||||
|
Loading…
Reference in New Issue
Block a user