From b00bf2bc6b024142377de08cdb8ea4490ff29f42 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 16 May 2022 15:23:17 -0700 Subject: [PATCH] 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 0d93be0af25bc60410647b2501fd2a2211e86ee9) --- pcbnew/widgets/appearance_controls.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index b7cab9e14d..54daadb3e8 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -1786,7 +1786,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 ); @@ -1797,7 +1797,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 );