diff --git a/OpenRA.Game/Map/MapCache.cs b/OpenRA.Game/Map/MapCache.cs index 5c6ce00eea..55002249b2 100644 --- a/OpenRA.Game/Map/MapCache.cs +++ b/OpenRA.Game/Map/MapCache.cs @@ -269,6 +269,9 @@ namespace OpenRA return; } + foreach (var p in previews.Values) + p.Dispose(); + // We need to let the loader thread exit before we can dispose our sheet builder. // Ideally we should dispose our resources before returning, but we don't to block waiting on the loader thread to exit. // Instead, we'll queue disposal to be run once it has exited. diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index e5cd1964d1..0877c9de83 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -53,7 +53,7 @@ namespace OpenRA public readonly bool downloading; } - public class MapPreview + public class MapPreview : IDisposable { static readonly CPos[] NoSpawns = new CPos[] { }; MapCache cache; @@ -344,5 +344,14 @@ namespace OpenRA { Status = MapStatus.Unavailable; } + + public void Dispose() + { + if (Package != null) + { + Package.Dispose(); + Package = null; + } + } } }