diff --git a/glx/glxext.c b/glx/glxext.c index 520eb2e3f..a571ec99a 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -128,8 +128,31 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) for (c = glxAllContexts; c; c = c->next) { if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) { + int i; + (*c->loseCurrent)(c); - __glXFlushContextCache(); + c->isCurrent = GL_FALSE; + if (c == __glXLastContext) + __glXFlushContextCache(); + + for (i = 1; i < currentMaxClients; i++) { + if (clients[i]) { + __GLXclientState *cl = glxGetClient(clients[i]); + + if (cl->inUse) { + int j; + + for (j = 0; j < cl->numCurrentContexts; j++) { + if (cl->currentContexts[j] == c) + cl->currentContexts[j] = NULL; + } + } + } + } + + if (!c->idExists) { + __glXFreeContext(c); + } } if (c->drawPriv == glxPriv) c->drawPriv = NULL;