From 4719a085bb8b83ed800eec9baa64e8aeff899e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 17 Apr 2016 14:09:52 +0200 Subject: [PATCH] Dispose global mix database.dat properly. --- OpenRA.Game/FileFormats/XccGlobalDatabase.cs | 14 ++++++++++++-- OpenRA.Game/FileSystem/MixFile.cs | 8 +++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/FileFormats/XccGlobalDatabase.cs b/OpenRA.Game/FileFormats/XccGlobalDatabase.cs index 1b29c4678d..31da6b6546 100644 --- a/OpenRA.Game/FileFormats/XccGlobalDatabase.cs +++ b/OpenRA.Game/FileFormats/XccGlobalDatabase.cs @@ -9,16 +9,21 @@ */ #endregion +using System; using System.Collections.Generic; using System.IO; namespace OpenRA.FileFormats { - public class XccGlobalDatabase + public class XccGlobalDatabase : IDisposable { public readonly string[] Entries; - public XccGlobalDatabase(Stream s) + readonly Stream s; + + public XccGlobalDatabase(Stream stream) { + s = stream; + var entries = new List(); while (s.Peek() > -1) { @@ -40,5 +45,10 @@ namespace OpenRA.FileFormats Entries = entries.ToArray(); } + + public void Dispose() + { + s.Dispose(); + } } } \ No newline at end of file diff --git a/OpenRA.Game/FileSystem/MixFile.cs b/OpenRA.Game/FileSystem/MixFile.cs index 4716f4c0e8..fee7538b2e 100644 --- a/OpenRA.Game/FileSystem/MixFile.cs +++ b/OpenRA.Game/FileSystem/MixFile.cs @@ -90,9 +90,11 @@ namespace OpenRA.FileSystem // TODO: This should be passed to the mix file ctor if (context.Exists("global mix database.dat")) { - var db = new XccGlobalDatabase(context.Open("global mix database.dat")); - foreach (var e in db.Entries) - allPossibleFilenames.Add(e); + using (var db = new XccGlobalDatabase(context.Open("global mix database.dat"))) + { + foreach (var e in db.Entries) + allPossibleFilenames.Add(e); + } } foreach (var filename in allPossibleFilenames)