-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
- !oldGC->isDirect && oldGC != &dummyContext) {
-#else
- if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
-#endif
- xGLXMakeCurrentReply dummy_reply;
-
- /* We are either switching from one dpy to another and have to
- * send a request to the previous dpy to unbind the previous
- * context, or we are switching away from a indirect context to
- * a direct context and have to send a request to the dpy to
- * unbind the previous context.
- */
- (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
- oldGC->currentContextTag, None, None,
- &dummy_reply);
- }
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- else if (oldGC->driContext && oldGC != gc) {
- oldGC->driContext->unbindContext(oldGC);
- }
-#endif
+ if (--oldGC->thread_refcount == 0) {
+ if (oldGC->xid != None &&
+ should_send(dpy, oldGC) &&
+ !SendMakeCurrentRequest(dpy, None, oldTag, None, None,
+ &oldGC->currentContextTag)) {
+ goto out;
+ }