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

@ -16,6 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
private readonly bool includeWeight;
private readonly ScoreType type;
private GetUserScoresRequest request;
public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string header, string missing, bool includeWeight = false)
: base(user, header, missing)
@ -32,9 +33,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
base.ShowMore();
var req = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
req.Success += scores =>
request = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
request.Success += scores => Schedule(() =>
{
foreach (var s in scores)
s.ApplyRuleset(Rulesets.GetRuleset(s.OnlineRulesetID));
@ -66,9 +66,15 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
ItemsContainer.Add(drawableScore);
}
};
});
Api.Queue(req);
Api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
request?.Cancel();
}
}
}