Revision: 36104 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36104 Author: nazgul Date: 2011-04-11 19:22:43 +0000 (Mon, 11 Apr 2011) Log Message: ----------- FIx crash when opening User Preferences even with NVidia card
This crash was discovered by Dalai and this happened because of unset current context (as result of call wglMakeCurrent(NULL, NULL)). In this case glGetString(GL_VENDOR) returns NULL. Rather than add check for vendor != NULL before string comparison, I've changed a bit logic of context creation: - Create context and set it as current - If it's crappy Intel card -- delete this context and share the only one context between all Windows - Otherwise, use initial logic (with sharing lists and so on) This could also fix crash when opening userprefs from a menu with Intel card. Modified Paths: -------------- trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp Modified: trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp =================================================================== --- trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2011-04-11 17:17:03 UTC (rev 36103) +++ trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2011-04-11 19:22:43 UTC (rev 36104) @@ -723,28 +723,47 @@ } // Create the context - if (s_firsthGLRc && is_crappy_intel_card()) { - m_hGlRc = s_firsthGLRc; - } else { - m_hGlRc = ::wglCreateContext(m_hDC); - - if (m_hGlRc) { + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { if (s_firsthGLRc) { - ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS); - ::wglShareLists(s_firsthGLRc, m_hGlRc); - } else { + if (is_crappy_intel_card()) { + if (::wglMakeCurrent(NULL, NULL) == TRUE) { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = s_firsthGLRc; + } + else { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = NULL; + } + } + else { + ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS); + ::wglShareLists(s_firsthGLRc, m_hGlRc); + } + } + else { s_firsthGLRc = m_hGlRc; } + + if (m_hGlRc) { + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + success = GHOST_kFailure; + } } + else { + success = GHOST_kFailure; + } } - - if (m_hGlRc) { - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; - } else { - printf("Failed to get a context....\n"); success = GHOST_kFailure; } + + if (success == GHOST_kFailure) { + printf("Failed to get a context....\n"); + } } else { @@ -766,27 +785,46 @@ ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat); // Create the context - if (s_firsthGLRc && is_crappy_intel_card()) { - m_hGlRc = s_firsthGLRc; - } else { - m_hGlRc = ::wglCreateContext(m_hDC); - - if (m_hGlRc) { + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { if (s_firsthGLRc) { - ::wglShareLists(s_firsthGLRc, m_hGlRc); - } else { + if (is_crappy_intel_card()) { + if (::wglMakeCurrent(NULL, NULL) == TRUE) { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = s_firsthGLRc; + } + else { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = NULL; + } + } + else { + ::wglShareLists(s_firsthGLRc, m_hGlRc); + } + } + else { s_firsthGLRc = m_hGlRc; } + + if (m_hGlRc) { + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + success = GHOST_kFailure; + } } + else { + success = GHOST_kFailure; + } } - - if (m_hGlRc) { - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; - } else { - printf("Failed to get a context....\n"); success = GHOST_kFailure; } + + if (success == GHOST_kFailure) { + printf("Failed to get a context....\n"); + } // Attempt to enable multisample if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs