forked from bartvdbraak/blender
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.
This commit is contained in:
parent
9699592628
commit
e210d82f17
@ -723,28 +723,47 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp
|
||||
}
|
||||
|
||||
// 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 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp
|
||||
::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)
|
||||
|
Loading…
Reference in New Issue
Block a user