Don't get stuck cycling through invisible layers.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16019
This commit is contained in:
Jeff Young 2023-11-03 18:17:09 +00:00
parent bc99b42c08
commit ac172b944a
1 changed files with 26 additions and 2 deletions

View File

@ -413,6 +413,7 @@ int PCB_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
BOARD* brd = board(); BOARD* brd = board();
int layer = editFrame->GetActiveLayer(); int layer = editFrame->GetActiveLayer();
int startLayer = layer; int startLayer = layer;
bool wraparound = false;
while( startLayer != ++layer ) while( startLayer != ++layer )
{ {
@ -420,8 +421,19 @@ int PCB_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
break; break;
if( layer >= B_Cu ) if( layer >= B_Cu )
{
if( wraparound )
{
wxBell();
return 0;
}
else
{
wraparound = true;
layer = F_Cu - 1; layer = F_Cu - 1;
} }
}
}
wxCHECK( IsCopperLayer( layer ), 0 ); wxCHECK( IsCopperLayer( layer ), 0 );
editFrame->SwitchLayer( ToLAYER_ID( layer ) ); editFrame->SwitchLayer( ToLAYER_ID( layer ) );
@ -436,6 +448,7 @@ int PCB_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
BOARD* brd = board(); BOARD* brd = board();
int layer = editFrame->GetActiveLayer(); int layer = editFrame->GetActiveLayer();
int startLayer = layer; int startLayer = layer;
bool wraparound = false;
while( startLayer != --layer ) while( startLayer != --layer )
{ {
@ -446,8 +459,19 @@ int PCB_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
} }
if( layer <= F_Cu ) if( layer <= F_Cu )
{
if( wraparound )
{
wxBell();
return 0;
}
else
{
wraparound = true;
layer = B_Cu + 1; layer = B_Cu + 1;
} }
}
}
wxCHECK( IsCopperLayer( layer ), 0 ); wxCHECK( IsCopperLayer( layer ), 0 );
editFrame->SwitchLayer( ToLAYER_ID( layer ) ); editFrame->SwitchLayer( ToLAYER_ID( layer ) );