Delete GL context in GL destructor not program
Also lock the DeleteAll call with mutext to protect threaded access. The OpenGL contexts are removed when OPENGL_GAL class is destroyed. Explicitly deleting all contexts prior to destroying the OPENGL_GAL class causes an assert when the destructor tries to lock its context prior to cleaning up OpenGL memory. In most cases, an unhandled assert in a destructor-called function will simply exit the destructor. Python thread cleanup will also attempt to close the context. This can cause a race condition with multiple threads accessing/deleting the canvas. Fixes: lp:1774096 * https://bugs.launchpad.net/kicad/+bug/1774096
This commit is contained in:
parent
bfa89039c4
commit
3cf9009f73
|
@ -65,10 +65,14 @@ void GL_CONTEXT_MANAGER::DestroyCtx( wxGLContext* aContext )
|
||||||
|
|
||||||
void GL_CONTEXT_MANAGER::DeleteAll()
|
void GL_CONTEXT_MANAGER::DeleteAll()
|
||||||
{
|
{
|
||||||
|
m_glCtxMutex.lock();
|
||||||
|
|
||||||
for( auto& ctx : m_glContexts )
|
for( auto& ctx : m_glContexts )
|
||||||
delete ctx.first;
|
delete ctx.first;
|
||||||
|
|
||||||
m_glContexts.clear();
|
m_glContexts.clear();
|
||||||
|
m_glCtx = NULL;
|
||||||
|
m_glCtxMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -372,12 +372,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
||||||
|
|
||||||
void IFACE::OnKifaceEnd()
|
void IFACE::OnKifaceEnd()
|
||||||
{
|
{
|
||||||
// This function deletes OpenGL contexts used (if any) by wxGLCanvas objects.
|
|
||||||
// It can be called only when closing the application, because it deletes an OpenGL context
|
|
||||||
// which can still be in usage. Destroying OpenGL contexts earlier may crash the application.
|
|
||||||
GL_CONTEXT_MANAGER::Get().DeleteAll();
|
|
||||||
|
|
||||||
end_common();
|
|
||||||
#if defined( KICAD_SCRIPTING_WXPYTHON )
|
#if defined( KICAD_SCRIPTING_WXPYTHON )
|
||||||
// Restore the thread state and tell Python to cleanup after itself.
|
// Restore the thread state and tell Python to cleanup after itself.
|
||||||
// wxPython will do its own cleanup as part of that process.
|
// wxPython will do its own cleanup as part of that process.
|
||||||
|
@ -386,4 +380,6 @@ void IFACE::OnKifaceEnd()
|
||||||
if( IsWxPythonLoaded() )
|
if( IsWxPythonLoaded() )
|
||||||
pcbnewFinishPythonScripting();
|
pcbnewFinishPythonScripting();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
end_common();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue