From 8f03b09dad2e755e368677b8570f776470e3823b Mon Sep 17 00:00:00 2001 From: thefiddler Date: Wed, 23 Jul 2014 09:21:28 +0200 Subject: [PATCH] [Mac] Register platform resources for disposal --- Source/OpenTK/Platform/MacOS/MacOSFactory.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/MacOSFactory.cs b/Source/OpenTK/Platform/MacOS/MacOSFactory.cs index 43e7bd7..091c115 100644 --- a/Source/OpenTK/Platform/MacOS/MacOSFactory.cs +++ b/Source/OpenTK/Platform/MacOS/MacOSFactory.cs @@ -49,22 +49,29 @@ namespace OpenTK.Platform.MacOS public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { - return new CocoaNativeWindow(x, y, width, height, title, mode, options, device); + INativeWindow window = new CocoaNativeWindow(x, y, width, height, title, mode, options, device); + RegisterResource(window); + return window; } public override IDisplayDeviceDriver CreateDisplayDeviceDriver() { + // Does not implement IDisposable return new QuartzDisplayDeviceDriver(); } public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) { - return new CocoaContext(mode, window, shareContext, major, minor); + IGraphicsContext context = new CocoaContext(mode, window, shareContext, major, minor); + RegisterResource(context); + return context; } public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) { - return new CocoaContext(handle, window, shareContext, major, minor); + IGraphicsContext context = new CocoaContext(handle, window, shareContext, major, minor); + RegisterResource(context); + return context; } public override GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext() @@ -98,12 +105,12 @@ namespace OpenTK.Platform.MacOS { if (!IsDisposed) { + base.Dispose(manual); + if (manual) { InputDriver.Dispose(); } - - base.Dispose(manual); } } -- 2.7.4