Don't lock OpenGL context twice

Use GAL_DRAWING_CONTEXT as this unlocks the context in its destructor,
so that when an exception is thrown inside the `try` block, it should
automatically unlock before we switch backend.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10840

(cherry picked from commit 1b6fe615e5)
This commit is contained in:
Roberto Fernandez Bautista 2022-02-13 18:40:30 +00:00
parent 30276fb5f7
commit b7f8f95725
1 changed files with 5 additions and 6 deletions

View File

@ -213,6 +213,7 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
try
{
cntUpd.Start();
try
{
m_view->UpdateItems();
@ -229,9 +230,7 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
cntUpd.Stop();
cntCtx.Start();
int cookie = rand();
m_gal->LockContext( cookie );
m_gal->BeginDrawing();
KIGFX::GAL_DRAWING_CONTEXT ctx( m_gal );
cntCtx.Stop();
if( m_view->IsTargetDirty( KIGFX::TARGET_OVERLAY )
@ -273,9 +272,6 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
cntCtxDestroy.Start();
m_gal->EndDrawing();
m_gal->UnlockContext( cookie );
cntCtxDestroy.Stop();
}
catch( std::exception& err )
{
@ -294,6 +290,9 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
}
}
// ctx goes out of scope here so destructor would be called
cntCtxDestroy.Stop();
if( isDirty )
{