mirror of https://github.com/ppy/osu
Fix nullref in case of successfull request but no backgrounds available
This commit is contained in:
parent
0b46c19b23
commit
51a58269ad
|
@ -32,7 +32,7 @@ private void load(SessionStatics sessionStatics, IAPIProvider api)
|
|||
request.Success += response =>
|
||||
{
|
||||
cachedResponse.Value = response;
|
||||
current = RNG.Next(0, cachedResponse.Value.Backgrounds.Count);
|
||||
current = RNG.Next(0, response.Backgrounds?.Count ?? 0);
|
||||
};
|
||||
|
||||
api.PerformAsync(request);
|
||||
|
@ -41,7 +41,7 @@ private void load(SessionStatics sessionStatics, IAPIProvider api)
|
|||
public SeasonalBackground LoadBackground()
|
||||
{
|
||||
var backgrounds = cachedResponse.Value.Backgrounds;
|
||||
if (!backgrounds.Any()) return null;
|
||||
if (backgrounds == null || !backgrounds.Any()) return null;
|
||||
|
||||
current = (current + 1) % backgrounds.Count;
|
||||
string url = backgrounds[current].Url;
|
||||
|
|
Loading…
Reference in New Issue