Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Mac] Explicitly retain/release CocoaWindowInfo instances

  • Loading branch information...
commit 1419c1e3a0913a678fde5e2429015f86ff045127 1 parent 290cc91
@thefiddler thefiddler authored
View
1  Source/OpenTK/Platform/MacOS/Cocoa/Selector.cs
@@ -38,6 +38,7 @@ static class Selector
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");
View
2  Source/OpenTK/Platform/MacOS/CocoaNativeWindow.cs
@@ -1021,7 +1021,7 @@ protected override void Dispose(bool disposing)
trackingArea = IntPtr.Zero;
}
- Cocoa.SendVoid(windowInfo.Handle, Selector.Release);
+ windowInfo.Dispose();
}
OnDisposed(EventArgs.Empty);
View
9 Source/OpenTK/Platform/MacOS/CocoaWindowInfo.cs
@@ -68,6 +68,7 @@ public CocoaWindowInfo(IntPtr nsWindowRef, IntPtr nsViewRef)
{
this.nsWindowRef = nsWindowRef;
this.nsViewRef = nsViewRef;
+ Cocoa.SendVoid(nsWindowRef, Selector.Retain);
}
#endregion
@@ -107,16 +108,22 @@ void Dispose(bool disposing)
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
}
Please sign in to comment.
Something went wrong with that request. Please try again.