Move early return out of the autorelease pool.
authorJarl Gullberg <jarl.gullberg@gmail.com>
Fri, 4 Aug 2017 16:39:44 +0000 (18:39 +0200)
committerJarl Gullberg <jarl.gullberg@gmail.com>
Fri, 4 Aug 2017 16:39:44 +0000 (18:39 +0200)
src/OpenTK/Platform/MacOS/CocoaContext.cs

index 67b68cb..eaae832 100644 (file)
@@ -340,18 +340,16 @@ namespace OpenTK
 
             Debug.Print("Disposing of Cocoa context.");
 
-            using (var pool = new NSAutoreleasePool())
+            if (!NSApplication.IsUIThread)
             {
-                if (!NSApplication.IsUIThread)
-                {
-                    return;
-
-                }
+                return;
+            }
 
+            using (var pool = new NSAutoreleasePool())
+            {
                 if (IsCurrent)
                 {
                     Cocoa.SendVoid(NSOpenGLContext, Selector.Get("clearCurrentContext"));
-
                 }
 
                 Cocoa.SendVoid(Handle.Handle, Selector.Get("clearDrawable"));