diff --git a/Source/OpenTK/Platform/MacOS/Cocoa/Selector.cs b/Source/OpenTK/Platform/MacOS/Cocoa/Selector.cs index 34b4da18..908aa090 100755 --- a/Source/OpenTK/Platform/MacOS/Cocoa/Selector.cs +++ b/Source/OpenTK/Platform/MacOS/Cocoa/Selector.cs @@ -38,6 +38,7 @@ namespace OpenTK.Platform.MacOS public static readonly IntPtr Init = Selector.Get("init"); public static readonly IntPtr InitWithCoder = Selector.Get("initWithCoder:"); public static readonly IntPtr Alloc = Selector.Get("alloc"); + public static readonly IntPtr Retain = Selector.Get("retain"); public static readonly IntPtr Release = Selector.Get("release"); public static readonly IntPtr Autorelease = Selector.Get("autorelease"); diff --git a/Source/OpenTK/Platform/MacOS/CocoaNativeWindow.cs b/Source/OpenTK/Platform/MacOS/CocoaNativeWindow.cs index f873ad3c..358d25a3 100644 --- a/Source/OpenTK/Platform/MacOS/CocoaNativeWindow.cs +++ b/Source/OpenTK/Platform/MacOS/CocoaNativeWindow.cs @@ -1021,7 +1021,7 @@ namespace OpenTK.Platform.MacOS trackingArea = IntPtr.Zero; } - Cocoa.SendVoid(windowInfo.Handle, Selector.Release); + windowInfo.Dispose(); } OnDisposed(EventArgs.Empty); diff --git a/Source/OpenTK/Platform/MacOS/CocoaWindowInfo.cs b/Source/OpenTK/Platform/MacOS/CocoaWindowInfo.cs index 5858f804..3c3f8bb3 100644 --- a/Source/OpenTK/Platform/MacOS/CocoaWindowInfo.cs +++ b/Source/OpenTK/Platform/MacOS/CocoaWindowInfo.cs @@ -68,6 +68,7 @@ namespace OpenTK.Platform.MacOS { this.nsWindowRef = nsWindowRef; this.nsViewRef = nsViewRef; + Cocoa.SendVoid(nsWindowRef, Selector.Retain); } #endregion @@ -107,16 +108,22 @@ namespace OpenTK.Platform.MacOS if (disposing) { - + Cocoa.SendVoid(nsWindowRef, Selector.Release); + } + else + { + Debug.Print("CocoaWindowInfo:{0} leaked, did you forget to call Dispose()?", nsWindowRef); } disposed = true; } + #if DEBUG ~CocoaWindowInfo() { Dispose(false); } + #endif #endregion }