1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Fix memory leaks from download buttons

This commit is contained in:
smoogipoo 2019-08-05 17:58:16 +09:00
parent be02019f5f
commit ee9e8f6261

View File

@ -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();