Skip to content
Browse files

Merge pull request #124 from thefiddler/xdestroyfix

[X11] Fixed BadWindow error on shutdown
  • Loading branch information...
2 parents ade8e61 + ec31675 commit 064fb628222c7e219d6c911850cea74fa503d165 @thefiddler thefiddler committed May 19, 2014
Showing with 11 additions and 21 deletions.
  1. +11 −21 Source/OpenTK/Platform/X11/X11GLNative.cs
View
32 Source/OpenTK/Platform/X11/X11GLNative.cs
@@ -831,12 +831,8 @@ public override void ProcessEvents()
if (!ce.Cancel)
{
isExiting = true;
-
- Debug.WriteLine("Destroying window.");
- using (new XLock(window.Display))
- {
- Functions.XDestroyWindow(window.Display, window.Handle);
- }
+ DestroyWindow();
+ OnClosed(EventArgs.Empty);
break;
}
}
@@ -846,9 +842,6 @@ public override void ProcessEvents()
case XEventName.DestroyNotify:
Debug.WriteLine("Window destroyed");
exists = false;
-
- OnClosed(EventArgs.Empty);
-
return;
case XEventName.ConfigureNotify:
@@ -1653,7 +1646,9 @@ public void DestroyWindow()
Debug.WriteLine("X11GLNative shutdown sequence initiated.");
using (new XLock(window.Display))
{
+ Functions.XSync(window.Display, true);
Functions.XDestroyWindow(window.Display, window.Handle);
+ exists = false;
}
}
@@ -1711,20 +1706,15 @@ protected override void Dispose(bool manuallyCalled)
{
if (window != null && window.Handle != IntPtr.Zero)
{
- if (Exists)
+ Functions.XFreeCursor(window.Display, EmptyCursor);
+ if(cursorHandle != IntPtr.Zero)
{
- using (new XLock(window.Display))
- {
- if(cursorHandle != IntPtr.Zero)
- {
- Functions.XFreeCursor(window.Display, cursorHandle);
- }
- Functions.XFreeCursor(window.Display, EmptyCursor);
- Functions.XDestroyWindow(window.Display, window.Handle);
- }
+ Functions.XFreeCursor(window.Display, cursorHandle);
+ }
- while (Exists)
- ProcessEvents();
+ if (Exists)
+ {
+ DestroyWindow();
}
window.Dispose();

0 comments on commit 064fb62

Please sign in to comment.
Something went wrong with that request. Please try again.