Delete OpenGL context on GLCanvas subclasses destruction.
This commit is contained in:
parent
68b6da57c0
commit
b83c148e10
|
@ -127,6 +127,7 @@ EDA_3D_CANVAS::~EDA_3D_CANVAS()
|
|||
delete m_model_parsers_list[i];
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ C3D_MODEL_VIEWER::~C3D_MODEL_VIEWER()
|
|||
m_ogl_3dmodel = NULL;
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ OPENGL_GAL::~OPENGL_GAL()
|
|||
}
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( glPrivContext );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,23 @@ wxGLContext* GL_CONTEXT_MANAGER::CreateCtx( wxGLCanvas* aCanvas, const wxGLConte
|
|||
}
|
||||
|
||||
|
||||
void GL_CONTEXT_MANAGER::DestroyCtx( wxGLContext* aContext )
|
||||
{
|
||||
assert( m_glCtx != aContext );
|
||||
|
||||
if( m_glContexts.count( aContext ) && m_glCtx != aContext )
|
||||
{
|
||||
m_glContexts.erase( aContext );
|
||||
delete aContext;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not delete currently used or unknown GL contexts
|
||||
assert( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GL_CONTEXT_MANAGER::DeleteAll()
|
||||
{
|
||||
for( auto& ctx : m_glContexts )
|
||||
|
|
|
@ -47,6 +47,14 @@ public:
|
|||
*/
|
||||
wxGLContext* CreateCtx( wxGLCanvas* aCanvas, const wxGLContext* aOther = NULL );
|
||||
|
||||
/**
|
||||
* Function DestroyCtx
|
||||
* destroys a managed OpenGL context. The context to be removed has to be created using
|
||||
* GL_CONTEXT_MANAGER::CreateCtx() first.
|
||||
* @param aContext is the OpenGL context to be destroyed. It will not be managed anymore.
|
||||
*/
|
||||
void DestroyCtx( wxGLContext* aContext );
|
||||
|
||||
/**
|
||||
* Function DeleteAll
|
||||
* destroys all managed OpenGL contexts. This method should be called in the
|
||||
|
|
Loading…
Reference in New Issue