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.
This commit is contained in:
parent
96073402ce
commit
eaf65f7d53
|
@ -261,11 +261,17 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
|||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
|
@ -2556,16 +2562,8 @@ void OPENGL_GAL::init()
|
|||
#endif /* wxCHECK_VERSION( 3, 0, 3 ) */
|
||||
|
||||
// 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 )
|
||||
throw std::runtime_error( "Could not create the m_tesselator" );
|
||||
// End initialization checks
|
||||
|
||||
throw std::runtime_error( "Could not create the tesselator" );
|
||||
GLenum err = glewInit();
|
||||
|
||||
if( GLEW_OK != err )
|
||||
|
|
|
@ -87,7 +87,8 @@ void GL_CONTEXT_MANAGER::DeleteAll()
|
|||
|
||||
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();
|
||||
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 )
|
||||
{
|
||||
wxCHECK( m_glContexts.count( aContext ) > 0, /* void */ );
|
||||
assert( aContext );
|
||||
wxCHECK( aContext && m_glContexts.count( aContext ) > 0, /* void */ );
|
||||
|
||||
if( m_glCtx == aContext )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue