Pcbnew: fix crash when trying to select the previous copper layer.

The function that calculates the previous layer id was using a illegal value
in some cases.

Fixes #3805
https://gitlab.com/kicad/code/kicad/issues/3805
This commit is contained in:
jean-pierre charras 2020-01-24 10:13:18 +01:00
parent bc68c7d949
commit d12e8479f2
1 changed files with 2 additions and 1 deletions

View File

@ -363,7 +363,8 @@ int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
while( startLayer != --layer )
{
if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
&& brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
break;
if( layer <= F_Cu )