mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 07:45:37 +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
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
~AglContext()
|
||||
{
|
||||
Dispose(false);
|
||||
|
@ -374,25 +375,20 @@ namespace OpenTK.Platform.MacOS
|
|||
return;
|
||||
|
||||
Debug.Print("Disposing of AGL context.");
|
||||
|
||||
try
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.StackTrace);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Handle = ContextHandle.Zero;
|
||||
return;
|
||||
Debug.Print("Context destruction completed successfully.");
|
||||
Handle = ContextHandle.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
// failed to destroy context.
|
||||
|
|
|
@ -124,6 +124,8 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
Debug.Print("Disposing of CarbonGLNative window.");
|
||||
|
||||
API.DisposeWindow(window.WindowRef);
|
||||
|
||||
mIsDisposed = true;
|
||||
mExists = false;
|
||||
|
||||
|
@ -136,6 +138,7 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
DisposeUPP();
|
||||
|
||||
}
|
||||
|
||||
~CarbonGLNative()
|
||||
|
@ -842,7 +845,15 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public void Close()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CancelEventArgs e = new CancelEventArgs();
|
||||
OnClosing(e);
|
||||
|
||||
if (e.Cancel)
|
||||
return;
|
||||
|
||||
OnClosed();
|
||||
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public WindowState WindowState
|
||||
|
|
Loading…
Reference in a new issue