[3/3] winex11.drv: Make wglMakeCurrent return the correct error when the drawable is invalid.

Matteo Bruni matteo.mystral at gmail.com
Tue Mar 29 09:42:25 CDT 2011


-------------- next part --------------
From 6fc78410aec903ea831035805db20b318917a4f5 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Thu, 17 Mar 2011 22:49:23 +0100
Subject: winex11.drv: Make wglMakeCurrent return the correct error when the drawable is invalid.

---
 dlls/opengl32/tests/opengl.c |    6 +++---
 dlls/winex11.drv/opengl.c    |    6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 8c81ba2..9834c6d 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -956,7 +956,7 @@ static void test_destroy(HDC oldhdc)
     SetLastError(0xdeadbeef);
     ret = wglMakeCurrent(dc, ctx);
     err = GetLastError();
-    todo_wine ok(!ret && err == ERROR_INVALID_HANDLE,
+    ok(!ret && err == ERROR_INVALID_HANDLE,
             "Unexpected behavior when making context current, ret %d, last error %#x.\n", ret, err);
 
     ok(wglGetCurrentContext() == ctx, "Wrong current context.\n");
@@ -977,7 +977,7 @@ static void test_destroy(HDC oldhdc)
     SetLastError(0xdeadbeef);
     ret = wglMakeCurrent(dc, ctx);
     err = GetLastError();
-    todo_wine ok(!ret && err == ERROR_INVALID_HANDLE,
+    ok(!ret && err == ERROR_INVALID_HANDLE,
             "Unexpected behavior when making context current, ret %d, last error %#x.\n", ret, err);
 
     ok(wglGetCurrentContext() == NULL, "Wrong current context.\n");
@@ -989,7 +989,7 @@ static void test_destroy(HDC oldhdc)
     SetLastError(0xdeadbeef);
     ret = wglMakeCurrent(dc, ctx);
     err = GetLastError();
-    todo_wine ok(!ret && err == ERROR_INVALID_HANDLE,
+    ok(!ret && err == ERROR_INVALID_HANDLE,
             "Unexpected behavior when making context current, ret %d, last error %#x.\n", ret, err);
 
     ok(wglGetCurrentContext() == oldctx, "Wrong current context.\n");
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 7df959d..6ced052 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1893,6 +1893,12 @@ BOOL CDECL X11DRV_wglMakeCurrent(X11DRV_PDEVICE *physDev, HGLRC hglrc) {
         ret = pglXMakeCurrent(gdi_display, None, NULL);
         NtCurrentTeb()->glContext = NULL;
     }
+    else if (!physDev->current_pf)
+    {
+        WARN("Trying to use an invalid drawable\n");
+        SetLastError(ERROR_INVALID_HANDLE);
+        ret = FALSE;
+    }
     else if (ctx->fmt->iPixelFormat != physDev->current_pf)
     {
         WARN( "mismatched pixel format hdc %p %u ctx %p %u\n",
-- 
1.7.3.4


More information about the wine-patches mailing list