[3/6] winex11.drv: Fix wglMakeContextCurrent with an invalid drawable.

Matteo Bruni matteo.mystral at gmail.com
Wed Mar 30 17:19:05 CDT 2011


-------------- next part --------------
From af2a3ecf579ba9d1bc8f674608853ed635ba1dcb Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Wed, 16 Mar 2011 00:32:47 +0100
Subject: winex11.drv: Fix wglMakeContextCurrent with an invalid drawable.

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

diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 7b6c911..1669d73 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -1129,10 +1129,10 @@ static void test_destroy_read(HDC oldhdc)
     SetLastError(0xdeadbeef);
     ret = pwglMakeContextCurrentARB(draw_dc, read_dc, ctx);
     err = GetLastError();
-    todo_wine ok(!ret && (err == ERROR_INVALID_HANDLE || err == 0xc0070006),
+    ok(!ret && (err == ERROR_INVALID_HANDLE || err == 0xc0070006),
             "Unexpected behavior when making context current, ret %d, last error %#x.\n", ret, err);
 
-    todo_wine ok(wglGetCurrentContext() == NULL, "Wrong current context.\n");
+    ok(wglGetCurrentContext() == NULL, "Wrong current context.\n");
 
     wglMakeCurrent(NULL, NULL);
 
@@ -1142,10 +1142,10 @@ static void test_destroy_read(HDC oldhdc)
     SetLastError(0xdeadbeef);
     ret = pwglMakeContextCurrentARB(draw_dc, read_dc, ctx);
     err = GetLastError();
-    todo_wine ok(!ret && (err == ERROR_INVALID_HANDLE || err == 0xc0070006),
+    ok(!ret && (err == ERROR_INVALID_HANDLE || err == 0xc0070006),
             "Unexpected behavior when making context current, last error %#x.\n", err);
 
-    todo_wine ok(wglGetCurrentContext() == oldctx, "Wrong current context.\n");
+    ok(wglGetCurrentContext() == oldctx, "Wrong current context.\n");
 
     ret = wglDeleteContext(ctx);
     ok(ret, "Failed to delete GL context, last error %#x.\n", GetLastError());
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 1d2eacf..81979ae 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1972,6 +1972,12 @@ BOOL CDECL X11DRV_wglMakeContextCurrentARB(X11DRV_PDEVICE* pDrawDev, X11DRV_PDEV
         ret = pglXMakeCurrent(gdi_display, None, NULL);
         NtCurrentTeb()->glContext = NULL;
     }
+    else if (!pDrawDev->current_pf)
+    {
+        WARN("Trying to use an invalid drawable\n");
+        SetLastError(ERROR_INVALID_HANDLE);
+        ret = FALSE;
+    }
     else
     {
         if (NULL == pglXMakeContextCurrent) {
-- 
1.7.3.4


More information about the wine-patches mailing list