[PATCH 1/6] glx: Do something unpleasant to current drawable tracking

Adam Jackson ajax at redhat.com
Mon Mar 14 12:31:24 PDT 2011


This is wrong, very wrong.  Almost as wrong as what it replaces.  Do not
merge me, ever.
---
 glx/glxcmds.c |    6 ++++--
 glx/glxext.c  |   12 ++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 9b4bc9e..59df1c8 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -643,8 +643,10 @@ DoMakeCurrent(__GLXclientState *cl,
 	/*
 	** Make the previous context not current.
 	*/
-	if (!(*prevglxc->loseCurrent)(prevglxc)) {
-	    return __glXError(GLXBadContext);
+	if (prevglxc->readPriv && prevglxc->drawPriv) {
+	    if (!(*prevglxc->loseCurrent)(prevglxc)) {
+		return __glXError(GLXBadContext);
+	    }
 	}
 	__glXFlushContextCache();
 	if (!prevglxc->isDirect) {
diff --git a/glx/glxext.c b/glx/glxext.c
index 4bd5d6b..90711f4 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -145,6 +145,7 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
 	    if (c == __glXLastContext)
 		__glXFlushContextCache();
 
+#if 0
 	    for (i = 1; i < currentMaxClients; i++) {
 		if (clients[i]) {
 		    __GLXclientState *cl = glxGetClient(clients[i]);
@@ -159,13 +160,16 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
 		    }
 		}
 	    }
+#endif
 	}
 	if (c->drawPriv == glxPriv)
 	    c->drawPriv = NULL;
 	if (c->readPriv == glxPriv)
 	    c->readPriv = NULL;
+#if 0
 	if (!c->idExists && !c->isCurrent)
 	    __glXFreeContext(c);
+#endif
     }
 
     glxPriv->destroy(glxPriv);
@@ -439,6 +443,14 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
 	    *error = __glXError(GLXBadCurrentWindow);
 	    return 0;
     	}
+	if (cx->readPriv == NULL) {
+	    /*
+	     * hack of the century
+	     */
+	    __glXFlushContextCache();
+	    *error = 0;
+	    return NULL;
+	}
     }
     
     if (cx->wait && (*cx->wait)(cx, cl, error))
-- 
1.7.3.5



More information about the xorg-devel mailing list