Henri Verbeet : wined3d: Make sure we release the correct DC in context_update_window().
Module: wine Branch: master Commit: 82e39ced7f3c2c513c95b4e52c446d23d4e2946b URL: http://source.winehq.org/git/wine.git/?a=commit;h=82e39ced7f3c2c513c95b4e52c... Author: Henri Verbeet <hverbeet(a)codeweavers.com> Date: Thu Apr 21 22:39:29 2011 +0200 wined3d: Make sure we release the correct DC in context_update_window(). --- 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());
participants (1)
-
Alexandre Julliard