[2/6] winex11.drv: Don't modify state if glXMakeContextCurrent fails.

Matteo Bruni matteo.mystral at gmail.com
Wed Mar 30 17:18:48 CDT 2011


-------------- next part --------------
From 5aa50a7a448a3aea5030184301fd8b5d99ef7e0c Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri, 11 Mar 2011 21:47:32 +0100
Subject: winex11.drv: Don't modify state if glXMakeContextCurrent fails.

---
 dlls/winex11.drv/opengl.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 0a23e44..1d2eacf 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1977,22 +1977,27 @@ BOOL CDECL X11DRV_wglMakeContextCurrentARB(X11DRV_PDEVICE* pDrawDev, X11DRV_PDEV
         if (NULL == pglXMakeContextCurrent) {
             ret = FALSE;
         } else {
-            Wine_GLContext *prev_ctx = NtCurrentTeb()->glContext;
             Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
             Drawable d_draw = get_glxdrawable(pDrawDev);
             Drawable d_read = get_glxdrawable(pReadDev);
 
-            if (prev_ctx) prev_ctx->tid = 0;
-
-            ctx->has_been_current = TRUE;
-            ctx->tid = GetCurrentThreadId();
-            ctx->hdc = pDrawDev->hdc;
-            ctx->read_hdc = pReadDev->hdc;
-            ctx->drawables[0] = d_draw;
-            ctx->drawables[1] = d_read;
-            ctx->refresh_drawables = FALSE;
             ret = pglXMakeContextCurrent(gdi_display, d_draw, d_read, ctx->ctx);
-            NtCurrentTeb()->glContext = ctx;
+            if (ret)
+            {
+                Wine_GLContext *prev_ctx = NtCurrentTeb()->glContext;
+                if (prev_ctx) prev_ctx->tid = 0;
+
+                ctx->has_been_current = TRUE;
+                ctx->tid = GetCurrentThreadId();
+                ctx->hdc = pDrawDev->hdc;
+                ctx->read_hdc = pReadDev->hdc;
+                ctx->drawables[0] = d_draw;
+                ctx->drawables[1] = d_read;
+                ctx->refresh_drawables = FALSE;
+                NtCurrentTeb()->glContext = ctx;
+            }
+            else
+                SetLastError(ERROR_INVALID_HANDLE);
         }
     }
     wine_tsx11_unlock();
-- 
1.7.3.4


More information about the wine-patches mailing list