Andrew Nguyen : winex11.drv: Set last error to ERROR_BUSY when attempting to delete a cross-thread context in wglDeleteContext .

Alexandre Julliard julliard at winehq.org
Mon Nov 8 11:46:26 CST 2010


Module: wine
Branch: master
Commit: 1579ab0e01b7639aab7d991c4864d6c4a9dd312f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1579ab0e01b7639aab7d991c4864d6c4a9dd312f

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Sun Nov  7 01:15:01 2010 -0500

winex11.drv: Set last error to ERROR_BUSY when attempting to delete a cross-thread context in wglDeleteContext.

---

 dlls/opengl32/tests/opengl.c |    4 ++++
 dlls/winex11.drv/opengl.c    |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 560efe1..65df28b 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -590,13 +590,16 @@ struct wgl_thread_param
     HANDLE test_finished;
     HGLRC hglrc;
     BOOL hglrc_deleted;
+    DWORD last_error;
 };
 
 static DWORD WINAPI wgl_thread(void *param)
 {
     struct wgl_thread_param *p = param;
 
+    SetLastError(0xdeadbeef);
     p->hglrc_deleted = wglDeleteContext(p->hglrc);
+    p->last_error = GetLastError();
     SetEvent(p->test_finished);
 
     return 0;
@@ -638,6 +641,7 @@ static void test_deletecontext(HDC hdc)
     {
         WaitForSingleObject(thread_handle, INFINITE);
         ok(thread_params.hglrc_deleted == FALSE, "Attempt to delete WGL context from another thread passed but should fail!\n");
+        ok(thread_params.last_error == ERROR_BUSY, "Expected last error to be ERROR_BUSY, got %u\n", thread_params.last_error);
     }
     CloseHandle(thread_params.test_finished);
 
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index ce909e6..8ea7ddb 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1793,6 +1793,7 @@ BOOL CDECL X11DRV_wglDeleteContext(HGLRC hglrc)
     if (ctx->tid != 0 && ctx->tid != GetCurrentThreadId())
     {
         TRACE("Cannot delete context=%p because it is current in another thread.\n", ctx);
+        SetLastError(ERROR_BUSY);
         return FALSE;
     }
 




More information about the wine-cvs mailing list