Merge pull request #10346 from RoosterDragon/misc-fixes

Dispose fixes + misc touchups
This commit is contained in:
Paul Chote
2016-01-01 13:53:05 +00:00
15 changed files with 72 additions and 20 deletions

View File

@@ -16,6 +16,7 @@ using System.Drawing.Imaging;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using OpenRA.Graphics;
using OpenRA.Primitives;
@@ -24,6 +25,7 @@ namespace OpenRA
{
public static class FieldLoader
{
[Serializable]
public class MissingFieldsException : YamlException
{
public readonly string[] Missing;
@@ -42,6 +44,13 @@ namespace OpenRA
Header = missing.Length > 1 ? header : headerSingle ?? header;
Missing = missing;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("Missing", Missing);
info.AddValue("Header", Header);
}
}
public static Func<string, Type, string, object> InvalidValueAction = (s, t, f) =>

View File

@@ -17,7 +17,7 @@ using ICSharpCode.SharpZipLib.Zip.Compression;
namespace OpenRA.FileSystem
{
public class InstallShieldCABExtractor : IFolder
public sealed class InstallShieldCABExtractor : IFolder
{
const uint FileSplit = 0x1;
const uint FileObfuscated = 0x2;

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Chat
}
}
public class GlobalChat : IDisposable
public sealed class GlobalChat : IDisposable
{
readonly IrcClient client = new IrcClient();
volatile Channel channel;

View File

@@ -17,7 +17,7 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public class HardwareCursor : ICursor
public sealed class HardwareCursor : ICursor
{
readonly Dictionary<string, IHardwareCursor[]> hardwareCursors = new Dictionary<string, IHardwareCursor[]>();
readonly CursorProvider cursorProvider;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Graphics
void Tick();
}
public class SoftwareCursor : ICursor
public sealed class SoftwareCursor : ICursor
{
readonly HardwarePalette palette = new HardwarePalette();
readonly Cache<string, PaletteReference> paletteReferences;

View File

@@ -17,7 +17,7 @@ using SharpFont;
namespace OpenRA.Graphics
{
public class SpriteFont
public sealed class SpriteFont : IDisposable
{
static readonly Library Library = new Library();
@@ -150,6 +150,11 @@ namespace OpenRA.Graphics
return g;
}
public void Dispose()
{
face.Dispose();
}
}
class GlyphInfo

View File

@@ -91,6 +91,9 @@ namespace OpenRA
public void InitializeFonts(Manifest m)
{
if (Fonts != null)
foreach (var font in Fonts.Values)
font.Dispose();
using (new Support.PerfTimer("SpriteFonts"))
{
if (fontSheetBuilder != null)
@@ -175,7 +178,7 @@ namespace OpenRA
public Size Resolution { get { return Device.WindowSize; } }
public interface IBatchRenderer { void Flush(); }
public interface IBatchRenderer { void Flush(); }
public IBatchRenderer CurrentBatchRenderer
{
@@ -254,6 +257,9 @@ namespace OpenRA
tempBuffer.Dispose();
if (fontSheetBuilder != null)
fontSheetBuilder.Dispose();
if (Fonts != null)
foreach (var font in Fonts.Values)
font.Dispose();
}
public string GetClipboardText()