fix: ITextureProvider thread-safety

This commit is contained in:
goat 2023-08-05 21:36:40 +02:00
parent 2bdc4445d4
commit b96ef30c20
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -1,4 +1,4 @@
using System; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -485,17 +485,17 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
#pragma warning disable SA1015 #pragma warning disable SA1015
[ResolveVia<ITextureProvider>] [ResolveVia<ITextureProvider>]
#pragma warning restore SA1015 #pragma warning restore SA1015
internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDisposable internal class TextureProviderPluginScoped : ITextureProvider, IServiceType, IDisposable
{ {
private readonly TextureManager textureManager; private readonly TextureManager textureManager;
private readonly List<TextureManagerTextureWrap> trackedTextures = new(); private readonly ConcurrentBag<TextureManagerTextureWrap> trackedTextures = new();
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TextureManagerPluginScoped"/> class. /// Initializes a new instance of the <see cref="TextureProviderPluginScoped"/> class.
/// </summary> /// </summary>
/// <param name="textureManager">TextureManager instance.</param> /// <param name="textureManager">TextureManager instance.</param>
public TextureManagerPluginScoped(TextureManager textureManager) public TextureProviderPluginScoped(TextureManager textureManager)
{ {
this.textureManager = textureManager; this.textureManager = textureManager;
} }