From 30bcaa966d6b00f1630609a78db18dee683cc43d Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Oct 2007 18:48:06 -0400 Subject: Make glx destroy path handle cases where the X window goes away first. --- GL/glx/glxdri.c | 19 ++++++++++++++----- GL/glx/glxext.c | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'GL') diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c index 3688d50a8..5c45cd190 100644 --- a/GL/glx/glxdri.c +++ b/GL/glx/glxdri.c @@ -185,10 +185,14 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable) (*private->driDrawable.destroyDrawable)(&private->driDrawable); - __glXenterServer(GL_FALSE); - DRIDestroyDrawable(drawable->pDraw->pScreen, - serverClient, drawable->pDraw); - __glXleaveServer(GL_FALSE); + /* If the X window was destroyed, the dri DestroyWindow hook will + * aready have taken care of this, so only call if pDraw isn't NULL. */ + if (drawable->pDraw != NULL) { + __glXenterServer(GL_FALSE); + DRIDestroyDrawable(drawable->pDraw->pScreen, + serverClient, drawable->pDraw); + __glXleaveServer(GL_FALSE); + } xfree(private); } @@ -668,11 +672,16 @@ getDrawableInfo(__DRIdrawable *driDrawable, { __GLXDRIdrawable *drawable = containerOf(driDrawable, __GLXDRIdrawable, driDrawable); - ScreenPtr pScreen = drawable->base.pDraw->pScreen; + ScreenPtr pScreen; drm_clip_rect_t *pClipRects, *pBackClipRects; GLboolean retval; size_t size; + /* If the X window has been destroyed, give up here. */ + if (drawable->base.pDraw == NULL) + return GL_FALSE; + + pScreen = drawable->base.pDraw->pScreen; __glXenterServer(GL_FALSE); retval = DRIGetDrawableInfo(pScreen, drawable->base.pDraw, index, stamp, x, y, width, height, diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c index 546d87f01..772538940 100644 --- a/GL/glx/glxext.c +++ b/GL/glx/glxext.c @@ -122,6 +122,8 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) cx->pendingState |= __GLX_PENDING_DESTROY; } + glxPriv->pDraw = NULL; + glxPriv->drawId = 0; __glXUnrefDrawable(glxPriv); return True; -- cgit v1.2.3