mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 15:35:34 +00:00
MacOS: Clean up AglContext destruction code.
Implement INativeWindow.Close method.
This commit is contained in:
parent
ed05d8e12c
commit
52e89c13b1
|
@ -358,6 +358,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
||||||
~AglContext()
|
~AglContext()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
|
@ -374,25 +375,20 @@ namespace OpenTK.Platform.MacOS
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug.Print("Disposing of AGL context.");
|
Debug.Print("Disposing of AGL context.");
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.WriteLine(e.StackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
Agl.aglSetCurrentContext(IntPtr.Zero);
|
Agl.aglSetCurrentContext(IntPtr.Zero);
|
||||||
Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
|
||||||
|
|
||||||
Debug.Print("Set drawable to null for context {0}.", Handle.Handle);
|
//Debug.Print("Setting drawable to null for context {0}.", Handle.Handle);
|
||||||
|
//Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
||||||
|
|
||||||
|
// I do not know MacOS allows us to destroy a context from a separate thread,
|
||||||
|
// like the finalizer thread. It's untested, but worst case is probably
|
||||||
|
// an exception on application exit, which would be logged to the console.
|
||||||
|
Debug.Print("Destroying context");
|
||||||
if (Agl.aglDestroyContext(Handle.Handle) == true)
|
if (Agl.aglDestroyContext(Handle.Handle) == true)
|
||||||
{
|
{
|
||||||
Handle = ContextHandle.Zero;
|
Debug.Print("Context destruction completed successfully.");
|
||||||
return;
|
Handle = ContextHandle.Zero;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// failed to destroy context.
|
// failed to destroy context.
|
||||||
|
|
|
@ -124,6 +124,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
Debug.Print("Disposing of CarbonGLNative window.");
|
Debug.Print("Disposing of CarbonGLNative window.");
|
||||||
|
|
||||||
|
API.DisposeWindow(window.WindowRef);
|
||||||
|
|
||||||
mIsDisposed = true;
|
mIsDisposed = true;
|
||||||
mExists = false;
|
mExists = false;
|
||||||
|
|
||||||
|
@ -136,6 +138,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeUPP();
|
DisposeUPP();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~CarbonGLNative()
|
~CarbonGLNative()
|
||||||
|
@ -842,7 +845,15 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
CancelEventArgs e = new CancelEventArgs();
|
||||||
|
OnClosing(e);
|
||||||
|
|
||||||
|
if (e.Cancel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OnClosed();
|
||||||
|
|
||||||
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WindowState WindowState
|
public WindowState WindowState
|
||||||
|
|
Loading…
Reference in a new issue