From bee3eb2c0afa2b15b080ad386fbc9707618eebc1 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 26 Feb 2016 08:46:07 +0000 Subject: [PATCH] Dispose MapPreviews and map packages. --- OpenRA.Game/Map/MapCache.cs | 3 +++ OpenRA.Game/Map/MapPreview.cs | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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; + } + } } }