wined3d: Make sure we release the correct DC in context_update_window().

This commit is contained in:
Henri Verbeet 2011-04-21 22:39:29 +02:00 committed by Alexandre Julliard
parent ac95c302ff
commit 82e39ced7f
1 changed files with 12 additions and 1 deletions

View File

@ -873,7 +873,18 @@ static void context_update_window(struct wined3d_context *context)
if (context->valid) 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", ERR("Failed to release device context %p, last error %#x.\n",
context->hdc, GetLastError()); context->hdc, GetLastError());