From 0d93be0af25bc60410647b2501fd2a2211e86ee9 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 --- 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 304ed80176..11db9966b5 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -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 );