wined3d: Cleanup after wglMakeCurrent() failures in context_set_current().
authorHenri Verbeet <hverbeet@codeweavers.com>
Wed, 23 Sep 2009 08:05:59 +0000 (10:05 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 23 Sep 2009 10:37:25 +0000 (12:37 +0200)
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

index e569e6eb3acf10ef1bf1deae316a42dd9325162e..935a92bc8561bb7c1299daf95635626ca9ad0651 100644 (file)
@@ -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;
         }
     }