Commit c4a8de92 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

winex11.drv: Ensure that the WGL context is removed from the context list in wglDeleteContext.

parent 4d86e491
...@@ -135,11 +135,18 @@ BOOL WINAPI wglDeleteContext(HGLRC hglrc) ...@@ -135,11 +135,18 @@ BOOL WINAPI wglDeleteContext(HGLRC hglrc)
TRACE("hglrc: (%p)\n", hglrc); TRACE("hglrc: (%p)\n", hglrc);
if(ctx == NULL) if(ctx == NULL)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
}
/* Retrieve the HDC associated with the context to access the display driver */ /* Retrieve the HDC associated with the context to access the display driver */
dc = get_dc_ptr(ctx->hdc); dc = get_dc_ptr(ctx->hdc);
if (!dc) return FALSE; if (!dc)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!dc->funcs->pwglDeleteContext) FIXME(" :stub\n"); if (!dc->funcs->pwglDeleteContext) FIXME(" :stub\n");
else ret = dc->funcs->pwglDeleteContext(hglrc); else ret = dc->funcs->pwglDeleteContext(hglrc);
......
...@@ -609,6 +609,11 @@ static void test_deletecontext(HDC hdc) ...@@ -609,6 +609,11 @@ static void test_deletecontext(HDC hdc)
HANDLE thread_handle; HANDLE thread_handle;
DWORD res, tid; DWORD res, tid;
SetLastError(0xdeadbeef);
res = wglDeleteContext(NULL);
ok(res == FALSE, "wglDeleteContext succeeded\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected last error to be ERROR_INVALID_HANDLE, got %u\n", GetLastError());
if(!hglrc) if(!hglrc)
{ {
skip("wglCreateContext failed!\n"); skip("wglCreateContext failed!\n");
...@@ -639,6 +644,12 @@ static void test_deletecontext(HDC hdc) ...@@ -639,6 +644,12 @@ static void test_deletecontext(HDC hdc)
res = wglDeleteContext(hglrc); res = wglDeleteContext(hglrc);
ok(res == TRUE, "wglDeleteContext failed\n"); ok(res == TRUE, "wglDeleteContext failed\n");
/* Attempting to delete the same context twice should fail. */
SetLastError(0xdeadbeef);
res = wglDeleteContext(hglrc);
ok(res == FALSE, "wglDeleteContext succeeded\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected last error to be ERROR_INVALID_HANDLE, got %u\n", GetLastError());
/* WGL makes a context not current when deleting it. This differs from GLX behavior where /* WGL makes a context not current when deleting it. This differs from GLX behavior where
* deletion takes place when the thread becomes not current. */ * deletion takes place when the thread becomes not current. */
hglrc = wglGetCurrentContext(); hglrc = wglGetCurrentContext();
......
...@@ -1807,6 +1807,7 @@ BOOL CDECL X11DRV_wglDeleteContext(HGLRC hglrc) ...@@ -1807,6 +1807,7 @@ BOOL CDECL X11DRV_wglDeleteContext(HGLRC hglrc)
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
free_context(ctx);
return TRUE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment