mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-22 20:45:38 +00:00
Moved the autorelease pool to the context.
This commit is contained in:
parent
5828203f8e
commit
a7ddb543a9
|
@ -54,6 +54,8 @@ namespace OpenTK
|
|||
"/System/Library/Frameworks/OpenGL.framework/OpenGLES",
|
||||
AddImageFlags.ReturnOnError);
|
||||
|
||||
private IntPtr autoreleasePool;
|
||||
|
||||
static CocoaContext()
|
||||
{
|
||||
Cocoa.Initialize();
|
||||
|
@ -117,6 +119,10 @@ namespace OpenTK
|
|||
|
||||
private void CreateContext(GraphicsMode mode, CocoaWindowInfo cocoaWindow, IntPtr shareContextRef, int majorVersion, int minorVersion, bool fullscreen)
|
||||
{
|
||||
// Create a new autorelease pool for allocations in this context (mach ports, etc)
|
||||
autoreleasePool = Cocoa.SendIntPtr(Class.NSAutoreleasePool, Selector.Get("alloc"));
|
||||
autoreleasePool = Cocoa.SendIntPtr(autoreleasePool, Selector.Get("init"));
|
||||
|
||||
// Prepare attributes
|
||||
IntPtr pixelFormat = SelectPixelFormat(mode, majorVersion, minorVersion);
|
||||
if (pixelFormat == IntPtr.Zero)
|
||||
|
@ -352,6 +358,12 @@ namespace OpenTK
|
|||
Cocoa.SendVoid(Handle.Handle, Selector.Get("clearDrawable"));
|
||||
Cocoa.SendVoid(Handle.Handle, Selector.Get("release"));
|
||||
|
||||
// Drain the autorelease pool for the context, closing mach ports (if there is one)
|
||||
if (autoreleasePool != IntPtr.Zero)
|
||||
{
|
||||
Cocoa.SendVoid(autoreleasePool, Selector.Get("drain"));
|
||||
}
|
||||
|
||||
Handle = ContextHandle.Zero;
|
||||
|
||||
IsDisposed = true;
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
private CocoaWindowInfo windowInfo;
|
||||
private IntPtr autoreleasePool;
|
||||
|
||||
private IntPtr windowClass;
|
||||
private IntPtr trackingArea;
|
||||
private IntPtr current_icon_handle;
|
||||
|
@ -158,10 +158,6 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public CocoaNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
// Create a new autorelease pool for allocations in this window (mach ports, etc)
|
||||
autoreleasePool = Cocoa.SendIntPtr(Class.NSAutoreleasePool, Selector.Get("alloc"));
|
||||
autoreleasePool = Cocoa.SendIntPtr(autoreleasePool, Selector.Get("init"));
|
||||
|
||||
// Create callback methods. We need to store those,
|
||||
// otherwise the GC may collect them while they are
|
||||
// still active.
|
||||
|
@ -1288,9 +1284,6 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
Debug.Print("[Mac] Disposing {0}", windowInfo);
|
||||
windowInfo.Dispose();
|
||||
|
||||
// Drain the autorelease pool for the application, closing mach ports
|
||||
Cocoa.SendVoid(autoreleasePool, Selector.Get("drain"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue