[PATCH 12/12] wined3d: Cleanup after wglMakeCurrent() failures in context_set_current().

Henri Verbeet hverbeet at codeweavers.com
Wed Sep 23 03:05:59 CDT 2009


The D3D context is potentially destroyed, so we need to clear the thread's
current D3D context. Found by Rico Schüller.
---
 dlls/wined3d/context.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e569e6e..935a92b 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -759,7 +759,10 @@ BOOL context_set_current(struct wined3d_context *ctx)
         TRACE("Switching to D3D context %p, GL context %p, device context %p.\n", ctx, ctx->glCtx, ctx->hdc);
         if (!pwglMakeCurrent(ctx->hdc, ctx->glCtx))
         {
-            ERR("Failed to make GL context %p current on device context %p.\n", ctx->glCtx, ctx->hdc);
+            DWORD err = GetLastError();
+            ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
+                    ctx->glCtx, ctx->hdc, err);
+            TlsSetValue(wined3d_context_tls_idx, NULL);
             return FALSE;
         }
         ctx->current = 1;
@@ -769,7 +772,9 @@ BOOL context_set_current(struct wined3d_context *ctx)
         TRACE("Clearing current D3D context.\n");
         if (!pwglMakeCurrent(NULL, NULL))
         {
-            ERR("Failed to clear current GL context.\n");
+            DWORD err = GetLastError();
+            ERR("Failed to clear current GL context, last error %#x.\n", err);
+            TlsSetValue(wined3d_context_tls_idx, NULL);
             return FALSE;
         }
     }
-- 
1.6.0.6




More information about the wine-patches mailing list