1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 13:47:21 +08:00

Add lock to ensure no threading shenanigans

This commit is contained in:
Dean Herbert 2021-10-12 13:04:18 +09:00
parent 077dcf5cd9
commit a849e7343e

View File

@ -41,6 +41,8 @@ namespace osu.Game.Skinning
protected virtual bool AllowColourLookup => true;
private readonly object sourceSetLock = new object();
/// <summary>
/// A dictionary mapping each <see cref="ISkin"/> source to a wrapper which handles lookup allowances.
/// </summary>
@ -173,6 +175,8 @@ namespace osu.Game.Skinning
/// </summary>
/// <param name="sources">The new sources.</param>
protected void SetSources(IEnumerable<ISkin> sources)
{
lock (sourceSetLock)
{
foreach (var skin in skinSources)
{
@ -188,6 +192,7 @@ namespace osu.Game.Skinning
source.SourceChanged += TriggerSourceChanged;
}
}
}
/// <summary>
/// Invoked when any source has changed (either <see cref="ParentSource"/> or sources replaced via <see cref="SetSources"/>).