Skip to content

Commit

Permalink
Merge pull request #26196 from bdach/fix-system-title-crash
Browse files Browse the repository at this point in the history
Fix crash when retrieval of system title image fails
  • Loading branch information
peppy authored Dec 28, 2023
2 parents 8e3fe09 + 7a10e13 commit 91f0603
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public void TestSystemTitle()
Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png",
Url = @"https://osu.ppy.sh/community/contests/189",
});
AddStep("set title with nonexistent image", () => Game.ChildrenOfType<SystemTitle>().Single().Current.Value = new APISystemTitle
{
Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2
Url = @"https://osu.ppy.sh/community/contests/189",
});
AddStep("unset system title", () => Game.ChildrenOfType<SystemTitle>().Single().Current.Value = null);
}
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/Menu/SystemTitle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public SystemTitleImage(APISystemTitle systemTitle)
[BackgroundDependencyLoader]
private void load(LargeTextureStore textureStore)
{
var texture = textureStore.Get(SystemTitle.Image);
if (SystemTitle.Image.Contains(@"@2x"))
Texture? texture = textureStore.Get(SystemTitle.Image);
if (texture != null && SystemTitle.Image.Contains(@"@2x"))
texture.ScaleAdjust *= 2;

AutoSizeAxes = Axes.Both;
Expand Down

0 comments on commit 91f0603

Please sign in to comment.