1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 20:22:55 +08:00

Merge pull request #15045 from peppy/fix-concurrent-hud-overlays

Fix two different skins displaying at the same time when rapidly switching
This commit is contained in:
Dan Balasescu 2021-10-11 16:40:04 +09:00 committed by GitHub
commit 2d178dd9dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -22,6 +23,8 @@ namespace osu.Game.Skinning
public bool ComponentsLoaded { get; private set; } public bool ComponentsLoaded { get; private set; }
private CancellationTokenSource cancellationSource;
public SkinnableTargetContainer(SkinnableTarget target) public SkinnableTargetContainer(SkinnableTarget target)
{ {
Target = target; Target = target;
@ -38,6 +41,9 @@ namespace osu.Game.Skinning
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer; content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer;
cancellationSource?.Cancel();
cancellationSource = null;
if (content != null) if (content != null)
{ {
LoadComponentAsync(content, wrapper => LoadComponentAsync(content, wrapper =>
@ -45,7 +51,7 @@ namespace osu.Game.Skinning
AddInternal(wrapper); AddInternal(wrapper);
components.AddRange(wrapper.Children.OfType<ISkinnableDrawable>()); components.AddRange(wrapper.Children.OfType<ISkinnableDrawable>());
ComponentsLoaded = true; ComponentsLoaded = true;
}); }, (cancellationSource = new CancellationTokenSource()).Token);
} }
else else
ComponentsLoaded = true; ComponentsLoaded = true;