mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Fix SpriteIcon potentially not updating texture during a load race condition
Better fix for #1577.
This commit is contained in:
parent
18e313b8f2
commit
7ff39d62a1
@ -57,19 +57,31 @@ namespace osu.Game.Graphics
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
private FontAwesome loadedIcon;
|
||||
private void updateTexture()
|
||||
{
|
||||
var texture = store?.Get(((char)icon).ToString());
|
||||
var loadableIcon = icon;
|
||||
|
||||
if (loadableIcon == loadedIcon) return;
|
||||
|
||||
var texture = store?.Get(((char)loadableIcon).ToString());
|
||||
|
||||
spriteMain.Texture = texture;
|
||||
spriteShadow.Texture = texture;
|
||||
|
||||
if (Size == Vector2.Zero)
|
||||
Size = new Vector2(texture?.DisplayWidth ?? 0, texture?.DisplayHeight ?? 0);
|
||||
|
||||
loadedIcon = loadableIcon;
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
|
Loading…
Reference in New Issue
Block a user