Merge pull request #5410 from RoosterDragon/IDisposable

Disposable fixup
This commit is contained in:
Paul Chote
2014-06-11 10:55:44 +12:00
37 changed files with 248 additions and 260 deletions

View File

@@ -29,11 +29,12 @@ namespace OpenRA.Renderer.Sdl2
}
}
public class Sdl2GraphicsDevice : IGraphicsDevice
public sealed class Sdl2GraphicsDevice : IGraphicsDevice
{
Size size;
Sdl2Input input;
IntPtr context, window;
bool disposed;
public Size WindowSize { get { return size; } }
@@ -101,10 +102,21 @@ namespace OpenRA.Renderer.Sdl2
input = new Sdl2Input();
}
public virtual void Quit()
public void Dispose()
{
SDL.SDL_GL_DeleteContext(context);
SDL.SDL_DestroyWindow(window);
if (disposed)
return;
disposed = true;
if (context != IntPtr.Zero)
{
SDL.SDL_GL_DeleteContext(context);
context = IntPtr.Zero;
}
if (window != IntPtr.Zero)
{
SDL.SDL_DestroyWindow(window);
window = IntPtr.Zero;
}
SDL.SDL_Quit();
}