mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:47:46 +08:00
Merge pull request #10862 from peppy/fix-currentskininfo-thread-safety
Move skin deletion logic to OsuGameBase to promote thread safety
This commit is contained in:
commit
08a127eedc
@ -194,6 +194,20 @@ namespace osu.Game
|
|||||||
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
||||||
dependencies.CacheAs<ISkinSource>(SkinManager);
|
dependencies.CacheAs<ISkinSource>(SkinManager);
|
||||||
|
|
||||||
|
// needs to be done here rather than inside SkinManager to ensure thread safety of CurrentSkinInfo.
|
||||||
|
SkinManager.ItemRemoved.BindValueChanged(weakRemovedInfo =>
|
||||||
|
{
|
||||||
|
if (weakRemovedInfo.NewValue.TryGetTarget(out var removedInfo))
|
||||||
|
{
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
// check the removed skin is not the current user choice. if it is, switch back to default.
|
||||||
|
if (removedInfo.ID == SkinManager.CurrentSkinInfo.Value.ID)
|
||||||
|
SkinManager.CurrentSkinInfo.Value = SkinInfo.Default;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dependencies.CacheAs(API ??= new APIAccess(LocalConfig));
|
dependencies.CacheAs(API ??= new APIAccess(LocalConfig));
|
||||||
|
|
||||||
dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient());
|
dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient());
|
||||||
|
@ -48,16 +48,6 @@ namespace osu.Game.Skinning
|
|||||||
this.audio = audio;
|
this.audio = audio;
|
||||||
this.legacyDefaultResources = legacyDefaultResources;
|
this.legacyDefaultResources = legacyDefaultResources;
|
||||||
|
|
||||||
ItemRemoved.BindValueChanged(weakRemovedInfo =>
|
|
||||||
{
|
|
||||||
if (weakRemovedInfo.NewValue.TryGetTarget(out var removedInfo))
|
|
||||||
{
|
|
||||||
// check the removed skin is not the current user choice. if it is, switch back to default.
|
|
||||||
if (removedInfo.ID == CurrentSkinInfo.Value.ID)
|
|
||||||
CurrentSkinInfo.Value = SkinInfo.Default;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
|
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
|
||||||
CurrentSkin.ValueChanged += skin =>
|
CurrentSkin.ValueChanged += skin =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user