[2/3] wined3d: Better handle some instances when we can't make the required GL context current.
Matteo Bruni
matteo.mystral at gmail.com
Thu Mar 31 16:21:24 CDT 2011
-------------- next part --------------
From 3d1006033cda8b252beef823c5f0a25de4da0bfe Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri, 18 Mar 2011 19:17:52 +0100
Subject: wined3d: Better handle some instances when we can't make the required GL context current.
---
dlls/wined3d/context.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 8413c42..c3a6a5f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1017,12 +1017,20 @@ BOOL context_set_current(struct wined3d_context *ctx)
if (ctx)
{
+ if (!ctx->valid)
+ {
+ ERR("Trying to make invalid context %p current\n", ctx);
+ return FALSE;
+ }
+
TRACE("Switching to D3D context %p, GL context %p, device context %p.\n", ctx, ctx->glCtx, ctx->hdc);
if (!pwglMakeCurrent(ctx->hdc, ctx->glCtx))
{
DWORD err = GetLastError();
ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
ctx->glCtx, ctx->hdc, err);
+ ctx->valid = 0;
+ pwglMakeCurrent(NULL, NULL);
TlsSetValue(wined3d_context_tls_idx, NULL);
return FALSE;
}
@@ -1063,6 +1071,7 @@ void context_release(struct wined3d_context *context)
DWORD err = GetLastError();
ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
context->restore_ctx, context->restore_dc, err);
+ context_set_current(NULL);
}
context->restore_ctx = NULL;
context->restore_dc = NULL;
@@ -2305,6 +2314,8 @@ struct wined3d_context *context_acquire(IWineD3DDeviceImpl *device, IWineD3DSurf
DWORD err = GetLastError();
ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
context->glCtx, context->hdc, err);
+ context->valid = 0;
+ pwglMakeCurrent(NULL, NULL);
}
}
--
1.7.3.4
More information about the wine-patches
mailing list