Fix potentially incorrect thread access in OsuTabControlCheckbox

https://github.com/ppy/osu/actions/runs/4868337922/jobs/8681736829.
This commit is contained in:
Dean Herbert
2023-05-03 14:33:30 +09:00
parent 6b017ac05f
commit a3efae3690

View File

@ -49,11 +49,10 @@ namespace osu.Game.Graphics.UserInterface
private const float transition_length = 500; private const float transition_length = 500;
private Sample sampleChecked; private Sample sampleChecked;
private Sample sampleUnchecked; private Sample sampleUnchecked;
private readonly SpriteIcon icon;
public OsuTabControlCheckbox() public OsuTabControlCheckbox()
{ {
SpriteIcon icon;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
@ -85,14 +84,6 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
} }
}; };
Current.ValueChanged += selected =>
{
icon.Icon = selected.NewValue ? FontAwesome.Regular.CheckCircle : FontAwesome.Regular.Circle;
text.Font = text.Font.With(weight: selected.NewValue ? FontWeight.Bold : FontWeight.Medium);
updateFade();
};
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -103,6 +94,14 @@ namespace osu.Game.Graphics.UserInterface
sampleChecked = audio.Samples.Get(@"UI/check-on"); sampleChecked = audio.Samples.Get(@"UI/check-on");
sampleUnchecked = audio.Samples.Get(@"UI/check-off"); sampleUnchecked = audio.Samples.Get(@"UI/check-off");
Current.ValueChanged += selected =>
{
icon.Icon = selected.NewValue ? FontAwesome.Regular.CheckCircle : FontAwesome.Regular.Circle;
text.Font = text.Font.With(weight: selected.NewValue ? FontWeight.Bold : FontWeight.Medium);
updateFade();
};
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)