Browse Source

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
7.0
Roberto Fernandez Bautista 4 years ago
parent
commit
1b6fe615e5
  1. 11
      common/draw_panel_gal.cpp

11
common/draw_panel_gal.cpp

@ -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 )
{

Loading…
Cancel
Save