Add some missing Dispose calls, fix some Dispose implementations.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Chat
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalChat : IDisposable
|
||||
public sealed class GlobalChat : IDisposable
|
||||
{
|
||||
readonly IrcClient client = new IrcClient();
|
||||
volatile Channel channel;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -124,12 +124,12 @@ namespace OpenRA.Mods.Cnc
|
||||
r.EndFrame(nih);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (sheet != null)
|
||||
if (disposing && sheet != null)
|
||||
sheet.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,12 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
Game.Settings.Save();
|
||||
}
|
||||
|
||||
public virtual void Dispose() { }
|
||||
protected virtual void Dispose(bool disposing) { }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +79,12 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
r.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (sheet != null)
|
||||
if (disposing && sheet != null)
|
||||
sheet.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class RadarWidget : Widget
|
||||
public sealed class RadarWidget : Widget, IDisposable
|
||||
{
|
||||
public string WorldInteractionController = null;
|
||||
public int AnimationLength = 5;
|
||||
@@ -447,6 +447,12 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
base.Removed();
|
||||
world.Map.MapTiles.Value.CellEntryChanged -= UpdateTerrainCell;
|
||||
world.Map.CustomTerrain.CellEntryChanged -= UpdateTerrainCell;
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
radarSheet.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,13 +304,24 @@ namespace OpenRA.Platforms.Default
|
||||
AL10.alListenerf(EFX.AL_METERS_PER_UNIT, .01f);
|
||||
}
|
||||
|
||||
~OpenAlSoundEngine()
|
||||
{
|
||||
Game.RunAfterTick(() => Dispose(false));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (device == IntPtr.Zero)
|
||||
return;
|
||||
Game.RunAfterTick(() => Dispose(true));
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
ALC10.alcCloseDevice(device);
|
||||
device = IntPtr.Zero;
|
||||
void Dispose(bool disposing)
|
||||
{
|
||||
if (device != IntPtr.Zero)
|
||||
{
|
||||
ALC10.alcCloseDevice(device);
|
||||
device = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user