Fix some web requests being run after disposal of their owner

This commit is contained in:
Dean Herbert
2018-09-05 10:23:23 +09:00
parent b0f9c0f6f0
commit 923acfbeaf
7 changed files with 56 additions and 30 deletions

View File

@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
public class PaginatedBeatmapContainer : PaginatedContainer
{
private const float panel_padding = 10f;
private readonly BeatmapSetType type;
private GetUserBeatmapsRequest request;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
: base(user, header, missing)
@ -31,9 +31,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
{
base.ShowMore();
var req = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
req.Success += sets =>
request = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
request.Success += sets => Schedule(() =>
{
ShowMoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
@ -52,9 +51,15 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
var panel = new DirectGridPanel(s.ToBeatmapSet(Rulesets));
ItemsContainer.Add(panel);
}
};
});
Api.Queue(req);
Api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
request?.Cancel();
}
}
}