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

(cherry picked from commit 0d93be0af2)
This commit is contained in:
Seth Hillbrand 2022-05-16 15:23:17 -07:00
parent 4b668269b7
commit b00bf2bc6b
1 changed files with 2 additions and 2 deletions

View File

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