Avoid deadlock when OpenGL context can't be created.
Previously, with aContext == nullptr, the mutex would lock, but not unlock.
Then it got deadlocked inside OPENGL_GAL dtor.
(cherry picked from commit eaf65f7d53
)
This commit is contained in:
parent
c919694f37
commit
1a3dc72af8
|
@ -260,11 +260,17 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
||||||
{
|
{
|
||||||
m_glMainContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
|
m_glMainContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
|
||||||
|
|
||||||
|
if( !m_glMainContext )
|
||||||
|
throw std::runtime_error( "Could not create the main OpenGL context" );
|
||||||
|
|
||||||
m_glPrivContext = m_glMainContext;
|
m_glPrivContext = m_glMainContext;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_glPrivContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this, m_glMainContext );
|
m_glPrivContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this, m_glMainContext );
|
||||||
|
|
||||||
|
if( !m_glPrivContext )
|
||||||
|
throw std::runtime_error( "Could not create a private OpenGL context" );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_shader = new SHADER();
|
m_shader = new SHADER();
|
||||||
|
@ -2533,16 +2539,8 @@ void OPENGL_GAL::init()
|
||||||
#endif /* wxCHECK_VERSION( 3, 0, 3 ) */
|
#endif /* wxCHECK_VERSION( 3, 0, 3 ) */
|
||||||
|
|
||||||
// Check correct initialization from the constructor
|
// Check correct initialization from the constructor
|
||||||
if( !m_glMainContext )
|
|
||||||
throw std::runtime_error( "Could not create the main OpenGL context" );
|
|
||||||
|
|
||||||
if( !m_glPrivContext )
|
|
||||||
throw std::runtime_error( "Could not create a private OpenGL context" );
|
|
||||||
|
|
||||||
if( m_tesselator == nullptr )
|
if( m_tesselator == nullptr )
|
||||||
throw std::runtime_error( "Could not create the m_tesselator" );
|
throw std::runtime_error( "Could not create the tesselator" );
|
||||||
// End initialization checks
|
|
||||||
|
|
||||||
GLenum err = glewInit();
|
GLenum err = glewInit();
|
||||||
|
|
||||||
if( GLEW_OK != err )
|
if( GLEW_OK != err )
|
||||||
|
|
|
@ -87,7 +87,8 @@ void GL_CONTEXT_MANAGER::DeleteAll()
|
||||||
|
|
||||||
void GL_CONTEXT_MANAGER::LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas )
|
void GL_CONTEXT_MANAGER::LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas )
|
||||||
{
|
{
|
||||||
wxCHECK( aCanvas || m_glContexts.count( aContext ) > 0, /* void */ );
|
assert( aContext );
|
||||||
|
wxCHECK( aContext && ( aCanvas || m_glContexts.count( aContext ) > 0 ), /* void */ );
|
||||||
|
|
||||||
m_glCtxMutex.lock();
|
m_glCtxMutex.lock();
|
||||||
wxGLCanvas* canvas = aCanvas ? aCanvas : m_glContexts.at( aContext );
|
wxGLCanvas* canvas = aCanvas ? aCanvas : m_glContexts.at( aContext );
|
||||||
|
@ -106,7 +107,8 @@ void GL_CONTEXT_MANAGER::LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas )
|
||||||
|
|
||||||
void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
|
void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
|
||||||
{
|
{
|
||||||
wxCHECK( m_glContexts.count( aContext ) > 0, /* void */ );
|
assert( aContext );
|
||||||
|
wxCHECK( aContext && m_glContexts.count( aContext ) > 0, /* void */ );
|
||||||
|
|
||||||
if( m_glCtx == aContext )
|
if( m_glCtx == aContext )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue