Andrew Nguyen : winex11.drv: Ensure that the WGL context is removed from the context list in wglDeleteContext .
Alexandre Julliard
julliard at winehq.org
Mon Nov 8 11:46:26 CST 2010
Module: wine
Branch: master
Commit: c4a8de92c4f49e281ad65b7213dff198869b3e66
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c4a8de92c4f49e281ad65b7213dff198869b3e66
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Sun Nov 7 01:14:44 2010 -0500
winex11.drv: Ensure that the WGL context is removed from the context list in wglDeleteContext.
---
dlls/gdi32/opengl.c | 9 ++++++++-
dlls/opengl32/tests/opengl.c | 11 +++++++++++
dlls/winex11.drv/opengl.c | 1 +
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/gdi32/opengl.c b/dlls/gdi32/opengl.c
index 9193fc5..8f91ae1 100644
--- a/dlls/gdi32/opengl.c
+++ b/dlls/gdi32/opengl.c
@@ -135,11 +135,18 @@ BOOL WINAPI wglDeleteContext(HGLRC hglrc)
TRACE("hglrc: (%p)\n", hglrc);
if(ctx == NULL)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
+ }
/* Retrieve the HDC associated with the context to access the display driver */
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");
else ret = dc->funcs->pwglDeleteContext(hglrc);
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index bf6269a..560efe1 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -609,6 +609,11 @@ static void test_deletecontext(HDC hdc)
HANDLE thread_handle;
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)
{
skip("wglCreateContext failed!\n");
@@ -639,6 +644,12 @@ static void test_deletecontext(HDC hdc)
res = wglDeleteContext(hglrc);
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
* deletion takes place when the thread becomes not current. */
hglrc = wglGetCurrentContext();
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 1191332..ce909e6 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1807,6 +1807,7 @@ BOOL CDECL X11DRV_wglDeleteContext(HGLRC hglrc)
wine_tsx11_unlock();
}
+ free_context(ctx);
return TRUE;
}
More information about the wine-cvs
mailing list