MacOS: Clean up AglContext destruction code.
Implement INativeWindow.Close method.
This commit is contained in:
parent
ed05d8e12c
commit
52e89c13b1
2 changed files with 23 additions and 16 deletions
|
@ -358,6 +358,7 @@ namespace OpenTK.Platform.MacOS
|
|||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
~AglContext()
|
||||
{
|
||||
Dispose(false);
|
||||
|
@ -374,23 +375,18 @@ 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)
|
||||
{
|
||||
Debug.Print("Context destruction completed successfully.");
|
||||
Handle = ContextHandle.Zero;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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