Don't allow footprint children in groups outside their footprint.

Fixes https://gitlab.com/kicad/code/kicad/issues/7625
This commit is contained in:
Jeff Young 2021-02-20 18:09:09 +00:00
parent 622baa6531
commit 9dacd4abb7
2 changed files with 58 additions and 6 deletions

View File

@ -808,7 +808,26 @@ void PCB_PARSER::resolveGroups( BOARD_ITEM* aParent )
item = getItem( aUuid ); item = getItem( aUuid );
if( item && item->Type() != NOT_USED ) if( item && item->Type() != NOT_USED )
{
switch( item->Type() )
{
// We used to allow fp items in non-footprint groups. It was a mistake.
case PCB_FP_TEXT_T:
case PCB_FP_SHAPE_T:
case PCB_FP_ZONE_T:
if( item->GetParent() == group->GetParent() )
group->AddItem( item ); group->AddItem( item );
break;
// This is the deleted item singleton, which means we didn't find the uuid.
case NOT_USED:
break;
default:
group->AddItem( item );
}
}
} }
} }

View File

@ -212,12 +212,45 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
int GROUP_TOOL::Group( const TOOL_EVENT& aEvent ) int GROUP_TOOL::Group( const TOOL_EVENT& aEvent )
{ {
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>(); PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
const PCB_SELECTION& selection = selTool->GetSelection(); PCB_SELECTION selection;
BOARD* board = getModel<BOARD>();
PCB_GROUP* group = nullptr; if( m_isFootprintEditor )
{
selection = selTool->RequestSelection(
[]( const VECTOR2I& , GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* )
{
} );
}
else
{
selection = selTool->RequestSelection(
[]( const VECTOR2I& , GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* )
{
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[ i ];
switch( item->Type() )
{
case PCB_FP_TEXT_T:
case PCB_FP_SHAPE_T:
case PCB_FP_ZONE_T:
aCollector.Remove( item );
break;
default:
break;
}
}
} );
}
if( selection.Empty() ) if( selection.Empty() )
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true ); return 0;
BOARD* board = getModel<BOARD>();
PCB_GROUP* group = nullptr;
if( m_isFootprintEditor ) if( m_isFootprintEditor )
{ {