From 6c881d78d7addee05830c8f366bf0167d70485c0 Mon Sep 17 00:00:00 2001 From: Nicholas Miell Date: Tue, 27 Dec 2011 17:10:36 -0800 Subject: [PATCH] Release GLX context before destroying the window GLEAN::Window::~Window was calling XDestroyWindow on the currently bound GLX drawable, which would cause the subsequent test to explode when it called glXMakeCurrent and Mesa attempted to flush the outstanding state to the now destroyed window. Now the Window destructor checks if the window being destroyed is bound to the current GLX context, and if so, releases the current GLX context before destroying the window. I also included the equivalent WGL change, but that is untested. The AGL and BeOS versions are untouched, but probably needs something similar. With this change, the glean basic sanity test now passes on Mesa swrast. Signed-off-by: Nicholas Miell --- tests/glean/dsurf.cpp | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/tests/glean/dsurf.cpp b/tests/glean/dsurf.cpp index 4e4cfd7..3683db1 100644 --- a/tests/glean/dsurf.cpp +++ b/tests/glean/dsurf.cpp @@ -198,8 +198,12 @@ DrawingSurface::commonDestructorCode() { Window::~Window() { #if defined(__X11__) + if (glXGetCurrentDrawable() == xWindow) + glXMakeCurrent(winSys->dpy, None, NULL); XDestroyWindow(winSys->dpy, xWindow); #elif defined(__WIN__) + if (wglGetCurrentDC() == hDC) + wglMakeCurrent(NULL, NULL); ReleaseDC(hWindow,hDC); DestroyWindow(hWindow); -- 1.7.7.4