Make sure that we have a visible layer

Before setting the active layer to our visible sequence, make sure that
the sequence is not empty (leads to invalid layer id->crash)

Fixes https://gitlab.com/kicad/code/kicad/issues/11629
This commit is contained in:
Seth Hillbrand 2022-05-16 15:23:17 -07:00
parent bda1f684fc
commit 0d93be0af2
1 changed files with 2 additions and 2 deletions

View File

@ -1784,7 +1784,7 @@ void APPEARANCE_CONTROLS::OnLayerContextMenu( wxCommandEvent& aEvent )
{
visible &= ~presetAllCopper.layers;
if( !visible.test( current ) )
if( !visible.test( current ) && visible.count() > 0 )
m_frame->SetActiveLayer( *visible.Seq().begin() );
setVisibleLayers( visible );
@ -1795,7 +1795,7 @@ void APPEARANCE_CONTROLS::OnLayerContextMenu( wxCommandEvent& aEvent )
{
visible &= presetAllCopper.layers;
if( !visible.test( current ) )
if( !visible.test( current ) && visible.count() > 0 )
m_frame->SetActiveLayer( *visible.Seq().begin() );
setVisibleLayers( visible );