Fix layer swapping for multi-layer items.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17371
This commit is contained in:
Jeff Young 2024-03-17 12:13:00 +00:00
parent 383dbd983a
commit 44c14b1935
1 changed files with 12 additions and 3 deletions

View File

@ -114,12 +114,21 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
bool GLOBAL_EDIT_TOOL::swapBoardItem( BOARD_ITEM* aItem,
std::map<PCB_LAYER_ID, PCB_LAYER_ID>& aLayerMap )
{
PCB_LAYER_ID original = aItem->GetLayer();
LSET originalLayers = aItem->GetLayerSet();
LSET newLayers;
if( aLayerMap.count( original ) && aLayerMap.at( original ) != original )
for( PCB_LAYER_ID original : originalLayers.Seq() )
{
if( aLayerMap.count( original ) )
newLayers.set( aLayerMap[ original ] );
else
newLayers.set( original );
}
if( originalLayers.Seq() != newLayers.Seq() )
{
m_commit->Modify( aItem );
aItem->SetLayer( aLayerMap.at( original ) );
aItem->SetLayerSet( newLayers );
frame()->GetCanvas()->GetView()->Update( aItem, KIGFX::GEOMETRY );
return true;
}