[Mac] Correctly release mach port

The event tap is released automatically along with the mach port. Fixes
crash on shutdown.
This commit is contained in:
thefiddler 2014-07-23 23:21:04 +02:00
parent 15f87c15a1
commit bb882fe700
2 changed files with 9 additions and 5 deletions

View file

@ -1756,13 +1756,11 @@ namespace OpenTK.Platform.MacOS
{
if (manual)
{
if (MouseEventTap != IntPtr.Zero)
{
CF.CFRelease(MouseEventTap);
MouseEventTap = IntPtr.Zero;
}
if (MouseEventTapSource != IntPtr.Zero)
{
// Note: releasing the mach port (tap source)
// automatically releases the event tap.
CF.RunLoopRemoveSource(RunLoop, MouseEventTapSource, CF.RunLoopModeDefault);
CF.CFRelease(MouseEventTapSource);
MouseEventTapSource = IntPtr.Zero;
}

View file

@ -233,5 +233,11 @@ namespace OpenTK.Platform.MacOS.Carbon
CFRunLoopRef rl,
CFRunLoopSourceRef source,
CFStringRef mode);
[DllImport(appServices, EntryPoint = "CFRunLoopRemoveSource")]
internal static extern void RunLoopRemoveSource(
CFRunLoopRef rl,
CFRunLoopSourceRef source,
CFStringRef mode);
}
}