Ensure dtor throws into catch block
Explicitly destruct the GAL context to get StopDrawing throws in the proper try block Fixes https://gitlab.com/kicad/code/kicad/issues/12117
This commit is contained in:
parent
c1da59b560
commit
519084546e
|
@ -254,49 +254,56 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
|
||||||
|
|
||||||
cntUpd.Stop();
|
cntUpd.Stop();
|
||||||
|
|
||||||
cntCtx.Start();
|
// GAL_DRAWING_CONTEXT can throw in the dtor, so we need to scope
|
||||||
KIGFX::GAL_DRAWING_CONTEXT ctx( m_gal );
|
// the full lifetime inside the try block
|
||||||
cntCtx.Stop();
|
|
||||||
|
|
||||||
if( m_view->IsTargetDirty( KIGFX::TARGET_OVERLAY )
|
|
||||||
&& !m_gal->HasTarget( KIGFX::TARGET_OVERLAY ) )
|
|
||||||
{
|
{
|
||||||
m_view->MarkDirty();
|
cntCtx.Start();
|
||||||
}
|
KIGFX::GAL_DRAWING_CONTEXT ctx( m_gal );
|
||||||
|
cntCtx.Stop();
|
||||||
|
|
||||||
m_gal->SetClearColor( settings->GetBackgroundColor() );
|
if( m_view->IsTargetDirty( KIGFX::TARGET_OVERLAY )
|
||||||
m_gal->SetGridColor( settings->GetGridColor() );
|
&& !m_gal->HasTarget( KIGFX::TARGET_OVERLAY ) )
|
||||||
m_gal->SetCursorColor( settings->GetCursorColor() );
|
|
||||||
|
|
||||||
// TODO: find why ClearScreen() must be called here in opengl mode
|
|
||||||
// and only if m_view->IsDirty() in Cairo mode to avoid display artifacts
|
|
||||||
// when moving the mouse cursor
|
|
||||||
if( m_backend == GAL_TYPE_OPENGL )
|
|
||||||
m_gal->ClearScreen();
|
|
||||||
|
|
||||||
if( m_view->IsDirty() )
|
|
||||||
{
|
|
||||||
if( m_backend != GAL_TYPE_OPENGL // Already called in opengl
|
|
||||||
&& m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
|
|
||||||
{
|
{
|
||||||
m_gal->ClearScreen();
|
m_view->MarkDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_view->ClearTargets();
|
m_gal->SetClearColor( settings->GetBackgroundColor() );
|
||||||
|
m_gal->SetGridColor( settings->GetGridColor() );
|
||||||
|
m_gal->SetCursorColor( settings->GetCursorColor() );
|
||||||
|
|
||||||
// Grid has to be redrawn only when the NONCACHED target is redrawn
|
// TODO: find why ClearScreen() must be called here in opengl mode
|
||||||
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
|
// and only if m_view->IsDirty() in Cairo mode to avoid display artifacts
|
||||||
m_gal->DrawGrid();
|
// when moving the mouse cursor
|
||||||
|
if( m_backend == GAL_TYPE_OPENGL )
|
||||||
|
m_gal->ClearScreen();
|
||||||
|
|
||||||
cntRedraw.Start();
|
if( m_view->IsDirty() )
|
||||||
m_view->Redraw();
|
{
|
||||||
cntRedraw.Stop();
|
if( m_backend != GAL_TYPE_OPENGL // Already called in opengl
|
||||||
isDirty = true;
|
&& m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
|
||||||
|
{
|
||||||
|
m_gal->ClearScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_view->ClearTargets();
|
||||||
|
|
||||||
|
// Grid has to be redrawn only when the NONCACHED target is redrawn
|
||||||
|
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
|
||||||
|
m_gal->DrawGrid();
|
||||||
|
|
||||||
|
cntRedraw.Start();
|
||||||
|
m_view->Redraw();
|
||||||
|
cntRedraw.Stop();
|
||||||
|
isDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
|
||||||
|
|
||||||
|
cntCtxDestroy.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
|
// ctx goes out of scope here so destructor would be called
|
||||||
|
cntCtxDestroy.Stop();
|
||||||
cntCtxDestroy.Start();
|
|
||||||
}
|
}
|
||||||
catch( std::exception& err )
|
catch( std::exception& err )
|
||||||
{
|
{
|
||||||
|
@ -315,10 +322,6 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ctx goes out of scope here so destructor would be called
|
|
||||||
cntCtxDestroy.Stop();
|
|
||||||
|
|
||||||
|
|
||||||
if( isDirty )
|
if( isDirty )
|
||||||
{
|
{
|
||||||
KI_TRACE( traceGalProfile, "View timing: %s %s %s %s %s\n",
|
KI_TRACE( traceGalProfile, "View timing: %s %s %s %s %s\n",
|
||||||
|
|
Loading…
Reference in New Issue