PANEL_SETUP_LAYERS: when removing a layer, do not delete items owned by footprints.

Items owned by footprints are allowed to be on non existing layers on board.
Moreover, items owned by footprint cannot be deleted by the board editor.
Fixes #17038
https://gitlab.com/kicad/code/kicad/-/issues/17038
This commit is contained in:
jean-pierre charras 2024-02-20 18:38:33 +01:00
parent 012b32e989
commit 01327b24b4
2 changed files with 25 additions and 1 deletions

View File

@ -503,6 +503,15 @@ bool PANEL_SETUP_LAYERS::TransferDataFromWindow()
for( int i = 0; i < collector.GetCount(); i++ )
{
BOARD_ITEM* item = collector[i];
// Do not remove/change an item owned by a footprint
if( dynamic_cast<FOOTPRINT*>( item->GetParentFootprint() ) )
continue;
// Do not remove footprints
if( dynamic_cast<FOOTPRINT*>( item ) )
continue;
LSET layers = item->GetLayerSet();
layers.reset( layer_id );
@ -728,7 +737,21 @@ LSEQ PANEL_SETUP_LAYERS::getRemovedLayersWithItems()
collector.Collect( m_pcb, GENERAL_COLLECTOR::BoardLevelItems );
if( collector.GetCount() != 0 )
removedLayers.push_back( layer_id );
{
// Skip items owned by footprints and footprints when building
// the actual list of removed layers: these items are not removed
for( int i = 0; i < collector.GetCount(); i++ )
{
BOARD_ITEM* item = collector[i];
if( dynamic_cast<FOOTPRINT*>( item )
|| dynamic_cast<FOOTPRINT*>( item->GetParentFootprint() ) )
continue;
removedLayers.push_back( layer_id );
break;
}
}
}
}

View File

@ -115,6 +115,7 @@ private:
/**
* Return a list of layers removed from the board that contain items.
* Footprints and items owned by footprints are not taken in account
*/
LSEQ getRemovedLayersWithItems();