* 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() public void ProcessEvents()
{ {
// Process all pending events // Process all pending events
if (!exists || window == null) while (Exists && window != null &&
return; Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) ||
while (Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) ||
Functions.XCheckTypedWindowEvent(window.Display, window.WindowHandle, XEventName.ClientMessage, ref e)) Functions.XCheckTypedWindowEvent(window.Display, window.WindowHandle, XEventName.ClientMessage, ref e))
{ {
// Respond to the event e // Respond to the event e
@ -585,8 +583,7 @@ namespace OpenTK.Platform.X11
break; break;
case XEventName.ClientMessage: case XEventName.ClientMessage:
Debug.WriteLine("Client message received."); if (!isExiting && e.ClientMessageEvent.ptr1 == _atom_wm_destroy)
if (e.ClientMessageEvent.ptr1 == _atom_wm_destroy)
{ {
Debug.WriteLine("Exit message received."); Debug.WriteLine("Exit message received.");
CancelEventArgs ce = new CancelEventArgs(); CancelEventArgs ce = new CancelEventArgs();
@ -615,7 +612,7 @@ namespace OpenTK.Platform.X11
if (Closed != null) if (Closed != null)
Closed(this, EventArgs.Empty); Closed(this, EventArgs.Empty);
break; return;
case XEventName.ConfigureNotify: case XEventName.ConfigureNotify:
border_width = e.ConfigureEvent.border_width; border_width = e.ConfigureEvent.border_width;
@ -1353,6 +1350,8 @@ namespace OpenTK.Platform.X11
if (manuallyCalled) if (manuallyCalled)
{ {
if (window != null && window.WindowHandle != IntPtr.Zero) if (window != null && window.WindowHandle != IntPtr.Zero)
{
if (Exists)
{ {
try try
{ {
@ -1366,6 +1365,7 @@ namespace OpenTK.Platform.X11
while (Exists) while (Exists)
ProcessEvents(); ProcessEvents();
}
if (GraphicsContext.CurrentContext != null) if (GraphicsContext.CurrentContext != null)
GraphicsContext.CurrentContext.MakeCurrent(null); GraphicsContext.CurrentContext.MakeCurrent(null);