From a25f7cc0a48058eda10dc47bd16d75244f52be97 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 18 Jul 2020 10:31:06 +0200 Subject: [PATCH] Pcbnew, footprint editor: make switching layers visibility on/off working. In footprint editor the board is a dummy board not managed by project settings, so using its settings to manage layers visibility does not work. Fixes #4924 https://gitlab.com/kicad/code/kicad/issues/4024 --- pcbnew/pcb_layer_widget.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index e016530ff9..896f3c0bf6 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -621,19 +621,26 @@ bool PCB_LAYER_WIDGET::OnLayerSelected() void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) { - BOARD* brd = myframe->GetBoard(); - - LSET visibleLayers = brd->GetVisibleLayers(); - - if( visibleLayers.test( aLayer ) != isVisible ) + // In other frames than board editor, the board is a dummy board. + // so changing board settings makes sense (and works) only for the board editor frame + if( myframe->IsType( FRAME_PCB_EDITOR ) ) { - visibleLayers.set( aLayer, isVisible ); + BOARD* brd = myframe->GetBoard(); - brd->SetVisibleLayers( visibleLayers ); + LSET visibleLayers = brd->GetVisibleLayers(); + if( visibleLayers.test( aLayer ) != isVisible ) + { + visibleLayers.set( aLayer, isVisible ); + brd->SetVisibleLayers( visibleLayers ); + + if( myframe->GetCanvas() ) + myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible ); + } + } + else if( myframe->GetCanvas() ) myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible ); - } if( isFinal ) myframe->GetCanvas()->Refresh();