Merge pull request #124 from thefiddler/xdestroyfix

[X11] Fixed BadWindow error on shutdown
This commit is contained in:
thefiddler 2014-05-19 23:14:32 +02:00
commit 064fb62822

View file

@ -831,12 +831,8 @@ namespace OpenTK.Platform.X11
if (!ce.Cancel) if (!ce.Cancel)
{ {
isExiting = true; isExiting = true;
DestroyWindow();
Debug.WriteLine("Destroying window."); OnClosed(EventArgs.Empty);
using (new XLock(window.Display))
{
Functions.XDestroyWindow(window.Display, window.Handle);
}
break; break;
} }
} }
@ -846,9 +842,6 @@ namespace OpenTK.Platform.X11
case XEventName.DestroyNotify: case XEventName.DestroyNotify:
Debug.WriteLine("Window destroyed"); Debug.WriteLine("Window destroyed");
exists = false; exists = false;
OnClosed(EventArgs.Empty);
return; return;
case XEventName.ConfigureNotify: case XEventName.ConfigureNotify:
@ -1653,7 +1646,9 @@ namespace OpenTK.Platform.X11
Debug.WriteLine("X11GLNative shutdown sequence initiated."); Debug.WriteLine("X11GLNative shutdown sequence initiated.");
using (new XLock(window.Display)) using (new XLock(window.Display))
{ {
Functions.XSync(window.Display, true);
Functions.XDestroyWindow(window.Display, window.Handle); Functions.XDestroyWindow(window.Display, window.Handle);
exists = false;
} }
} }
@ -1711,20 +1706,15 @@ namespace OpenTK.Platform.X11
{ {
if (window != null && window.Handle != IntPtr.Zero) if (window != null && window.Handle != IntPtr.Zero)
{ {
Functions.XFreeCursor(window.Display, EmptyCursor);
if(cursorHandle != IntPtr.Zero)
{
Functions.XFreeCursor(window.Display, cursorHandle);
}
if (Exists) if (Exists)
{ {
using (new XLock(window.Display)) DestroyWindow();
{
if(cursorHandle != IntPtr.Zero)
{
Functions.XFreeCursor(window.Display, cursorHandle);
}
Functions.XFreeCursor(window.Display, EmptyCursor);
Functions.XDestroyWindow(window.Display, window.Handle);
}
while (Exists)
ProcessEvents();
} }
window.Dispose(); window.Dispose();