From 7ff39d62a1e52170c43026bd98cc94554878493d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Nov 2017 12:46:15 +0900 Subject: [PATCH] Fix SpriteIcon potentially not updating texture during a load race condition Better fix for #1577. --- osu.Game/Graphics/SpriteIcon.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/SpriteIcon.cs b/osu.Game/Graphics/SpriteIcon.cs index ca108bfa7a..e752b1d91a 100644 --- a/osu.Game/Graphics/SpriteIcon.cs +++ b/osu.Game/Graphics/SpriteIcon.cs @@ -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)