mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0024747: TKOpenGl - Mesa fails to destroy context if it set to current thread
This commit is contained in:
parent
af324faa80
commit
544da5a477
@ -592,19 +592,18 @@ OpenGl_Window::~OpenGl_Window()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// release "GL" context if it is owned by window
|
// release "GL" context if it is owned by window
|
||||||
|
// Mesa implementation can fail to destroy GL context if it set for current thread.
|
||||||
|
// It should be safer to unset thread GL context before its destruction.
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
HWND aWindow = (HWND )myGlContext->myWindow;
|
HWND aWindow = (HWND )myGlContext->myWindow;
|
||||||
HDC aWindowDC = (HDC )myGlContext->myWindowDC;
|
HDC aWindowDC = (HDC )myGlContext->myWindowDC;
|
||||||
HGLRC aWindowGContext = (HGLRC )myGlContext->myGContext;
|
HGLRC aWindowGContext = (HGLRC )myGlContext->myGContext;
|
||||||
HGLRC aThreadGlContext = wglGetCurrentContext();
|
HGLRC aThreadGContext = wglGetCurrentContext();
|
||||||
myGlContext.Nullify();
|
myGlContext.Nullify();
|
||||||
|
|
||||||
if (aThreadGlContext != NULL)
|
if (aThreadGContext != NULL)
|
||||||
{
|
{
|
||||||
// Mesa implementation can fail to reset this thread's context if wglDeleteContext()
|
if (aThreadGContext == aWindowGContext)
|
||||||
// called without this step. This might lead to crash when using newly created
|
|
||||||
// context if wglMakeCurrent() is not forced right after the wglCreateContext().
|
|
||||||
if (aThreadGlContext == aWindowGContext)
|
|
||||||
{
|
{
|
||||||
wglMakeCurrent (NULL, NULL);
|
wglMakeCurrent (NULL, NULL);
|
||||||
}
|
}
|
||||||
@ -614,14 +613,20 @@ OpenGl_Window::~OpenGl_Window()
|
|||||||
ReleaseDC (aWindow, aWindowDC);
|
ReleaseDC (aWindow, aWindowDC);
|
||||||
#else
|
#else
|
||||||
Display* aDisplay = (Display* )myGlContext->myDisplay;
|
Display* aDisplay = (Display* )myGlContext->myDisplay;
|
||||||
GLXContext aGContext = (GLXContext )myGlContext->myGContext;
|
GLXContext aWindowGContext = (GLXContext )myGlContext->myGContext;
|
||||||
|
GLXContext aThreadGContext = glXGetCurrentContext();
|
||||||
myGlContext.Nullify();
|
myGlContext.Nullify();
|
||||||
|
|
||||||
if (aDisplay != NULL)
|
if (aDisplay != NULL)
|
||||||
{
|
{
|
||||||
|
if (aThreadGContext == aWindowGContext)
|
||||||
|
{
|
||||||
|
glXMakeCurrent (aDisplay, None, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// FSXXX sync necessary if non-direct rendering
|
// FSXXX sync necessary if non-direct rendering
|
||||||
glXWaitGL();
|
glXWaitGL();
|
||||||
glXDestroyContext (aDisplay, aGContext);
|
glXDestroyContext (aDisplay, aWindowGContext);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user