* X11GLNative.cs: Added more defensive checks for the existence of the window before issuing XDestroyWindow.

Do not allow multiple calls to XDestroyWindow once the shutdown sequence has been initialized. Fixes issue [#1190]: "GameWindow dispose on linux".
This commit is contained in:
the_fiddler 2009-10-19 19:46:37 +00:00
parent 162faad8e3
commit 2b7ed38569

View file

@ -551,10 +551,8 @@ namespace OpenTK.Platform.X11
public void ProcessEvents()
{
// Process all pending events
if (!exists || window == null)
return;
while (Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) ||
while (Exists && window != null &&
Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) ||
Functions.XCheckTypedWindowEvent(window.Display, window.WindowHandle, XEventName.ClientMessage, ref e))
{
// Respond to the event e
@ -585,8 +583,7 @@ namespace OpenTK.Platform.X11
break;
case XEventName.ClientMessage:
Debug.WriteLine("Client message received.");
if (e.ClientMessageEvent.ptr1 == _atom_wm_destroy)
if (!isExiting && e.ClientMessageEvent.ptr1 == _atom_wm_destroy)
{
Debug.WriteLine("Exit message received.");
CancelEventArgs ce = new CancelEventArgs();
@ -614,8 +611,8 @@ namespace OpenTK.Platform.X11
if (Closed != null)
Closed(this, EventArgs.Empty);
break;
return;
case XEventName.ConfigureNotify:
border_width = e.ConfigureEvent.border_width;
@ -1354,19 +1351,22 @@ namespace OpenTK.Platform.X11
{
if (window != null && window.WindowHandle != IntPtr.Zero)
{
try
if (Exists)
{
Functions.XLockDisplay(window.Display);
Functions.XDestroyWindow(window.Display, window.WindowHandle);
}
finally
{
Functions.XUnlockDisplay(window.Display);
}
while (Exists)
ProcessEvents();
try
{
Functions.XLockDisplay(window.Display);
Functions.XDestroyWindow(window.Display, window.WindowHandle);
}
finally
{
Functions.XUnlockDisplay(window.Display);
}
while (Exists)
ProcessEvents();
}
if (GraphicsContext.CurrentContext != null)
GraphicsContext.CurrentContext.MakeCurrent(null);