1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:07:33 +08:00

Merge pull request #17761 from peppy/fix-drawable-room-null-reference

Fix potential crash in `DrawableRoom` due to lack of null check on post-lookup beatmap
This commit is contained in:
Dan Balasescu 2022-04-11 14:50:01 +09:00 committed by GitHub
commit 489f064b13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
@ -34,9 +35,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestMultipleStatuses()
{
FillFlowContainer rooms = null;
AddStep("create rooms", () =>
{
Child = new FillFlowContainer
Child = rooms = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -124,6 +127,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
};
});
AddUntilStep("wait for panel load", () => rooms.Count == 5);
AddUntilStep("correct status text", () => rooms.ChildrenOfType<OsuSpriteText>().Count(s => s.Text.ToString().StartsWith("Currently playing", StringComparison.Ordinal)) == 2);
AddUntilStep("correct status text", () => rooms.ChildrenOfType<OsuSpriteText>().Count(s => s.Text.ToString().StartsWith("Ready to play", StringComparison.Ordinal)) == 3);
}
[Test]

View File

@ -418,10 +418,16 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
var retrievedBeatmap = task.GetResultSafely();
statusText.Text = "Currently playing ";
beatmapText.AddLink(retrievedBeatmap.GetDisplayTitleRomanisable(),
LinkAction.OpenBeatmap,
retrievedBeatmap.OnlineID.ToString(),
creationParameters: s => s.Truncate = true);
if (retrievedBeatmap != null)
{
beatmapText.AddLink(retrievedBeatmap.GetDisplayTitleRomanisable(),
LinkAction.OpenBeatmap,
retrievedBeatmap.OnlineID.ToString(),
creationParameters: s => s.Truncate = true);
}
else
beatmapText.AddText("unknown beatmap");
}), cancellationSource.Token);
}
}