[PATCH 2/5] wined3d: Make sure we release the correct DC in context_update_window().
Henri Verbeet
hverbeet at codeweavers.com
Thu Apr 21 15:39:29 CDT 2011
---
dlls/wined3d/context.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 18c9438..3d07a35 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -873,7 +873,18 @@ static void context_update_window(struct wined3d_context *context)
if (context->valid)
{
- if (!ReleaseDC(context->win_handle, context->hdc))
+ /* You'd figure ReleaseDC() would fail if the DC doesn't match the
+ * window. However, that's not what actually happens, and there are
+ * user32 tests that confirm ReleaseDC() with the wrong window is
+ * supposed to succeed. So explicitly check that the DC belongs to
+ * the window, since we want to avoid releasing a DC that belongs to
+ * some other window if the original window was already destroyed. */
+ if (WindowFromDC(context->hdc) != context->win_handle)
+ {
+ WARN("DC %p does not belong to window %p.\n",
+ context->hdc, context->win_handle);
+ }
+ else if (!ReleaseDC(context->win_handle, context->hdc))
{
ERR("Failed to release device context %p, last error %#x.\n",
context->hdc, GetLastError());
--
1.7.3.4
More information about the wine-patches
mailing list