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