opengl32: glGetString() requires an active GL context (try 3)
Bruno Jesus
00cpxxx at gmail.com
Tue Jun 24 19:39:07 CDT 2014
try 3:
Use a thread without active context to test just like the game does.
Without the change in wgl.c it will crash like http://ix.io/d8y
try2:
Add tests.
original:
The fix from bug 13599 was removed between 1.5.9 and 1.5.10:
http://source.winehq.org/source/dlls/opengl32/wgl.c?v=wine-1.5.9#L1270
http://source.winehq.org/source/dlls/opengl32/wgl.c?v=wine-1.5.10#L1547
See http://bugs.winehq.org/show_bug.cgi?id=36506#c6 for more info.
Fixes bug http://bugs.winehq.org/show_bug.cgi?id=36506
-------------- next part --------------
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 7384cb4..e5e1507 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -715,6 +715,9 @@ static DWORD WINAPI wgl_thread(void *param)
struct wgl_thread_param *p = param;
HDC hdc = GetDC( p->hwnd );
+ ok(!glGetString(GL_RENDERER) && !glGetString(GL_VERSION) && !glGetString(GL_VENDOR),
+ "Expected NULL string when no active context is set\n");
+
SetLastError(0xdeadbeef);
p->make_current = wglMakeCurrent(hdc, p->hglrc);
p->make_current_error = GetLastError();
@@ -1668,6 +1671,8 @@ START_TEST(opengl)
test_message_window();
test_dc(hwnd, hdc);
+ ok(!glGetString(GL_RENDERER) && !glGetString(GL_VERSION) && !glGetString(GL_VENDOR),
+ "Expected NULL string when no active context is set\n");
hglrc = wglCreateContext(hdc);
res = wglMakeCurrent(hdc, hglrc);
ok(res, "wglMakeCurrent failed!\n");
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 9255e34..f5adefd 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -1706,7 +1706,7 @@ static GLubyte *filter_extensions( const char *extensions )
const GLubyte * WINAPI glGetString( GLenum name )
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- const GLubyte *ret = funcs->gl.p_glGetString( name );
+ const GLubyte *ret = funcs ? funcs->gl.p_glGetString( name ) : NULL;
if (name == GL_EXTENSIONS && ret)
{
More information about the wine-patches
mailing list