1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Fix null reference causing crash in KiaiFlashingDrawable

Can occur if there is no fallback graphics available. Previously would
work as it was only setting the `Texture`.

As reported in https://github.com/ppy/osu/discussions/16281.
This commit is contained in:
Dean Herbert 2021-12-30 22:21:37 +09:00
parent 2fd4647e6e
commit 408e8d5710

View File

@ -7,6 +7,8 @@ using osu.Framework.Graphics;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
#nullable enable
namespace osu.Game.Rulesets.Osu.Skinning.Legacy namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{ {
internal class KiaiFlashingDrawable : BeatSyncedContainer internal class KiaiFlashingDrawable : BeatSyncedContainer
@ -15,18 +17,18 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private const float flash_opacity = 0.3f; private const float flash_opacity = 0.3f;
public KiaiFlashingDrawable(Func<Drawable> creationFunc) public KiaiFlashingDrawable(Func<Drawable?> creationFunc)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Children = new[] Children = new[]
{ {
creationFunc.Invoke().With(d => (creationFunc.Invoke() ?? Empty()).With(d =>
{ {
d.Anchor = Anchor.Centre; d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre; d.Origin = Anchor.Centre;
}), }),
flashingDrawable = creationFunc.Invoke().With(d => flashingDrawable = (creationFunc.Invoke() ?? Empty()).With(d =>
{ {
d.Anchor = Anchor.Centre; d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre; d.Origin = Anchor.Centre;