Skip newly-added footprints in connectivity

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9892
This commit is contained in:
Jon Evans 2021-12-08 20:38:59 -05:00
parent 230490d5d3
commit 44e01dcd0a
4 changed files with 27 additions and 4 deletions

View File

@ -118,8 +118,6 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
if( !aItem->IsOnCopperLayer() )
return false;
markItemNetAsDirty ( aItem );
switch( aItem->Type() )
{
case PCB_NETINFO_T:
@ -127,6 +125,10 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
break;
case PCB_FOOTPRINT_T:
{
if( static_cast<FOOTPRINT*>( aItem )->GetAttributes() & FP_JUST_ADDED )
return false;
for( PAD* pad : static_cast<FOOTPRINT*>( aItem )->Pads() )
{
if( m_itemMap.find( pad ) != m_itemMap.end() )
@ -136,13 +138,22 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
}
break;
}
case PCB_PAD_T:
if( m_itemMap.find ( aItem ) != m_itemMap.end() )
{
if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParentFootprint() ) )
{
if( fp->GetAttributes() & FP_JUST_ADDED )
return false;
}
if( m_itemMap.find( aItem ) != m_itemMap.end() )
return false;
add( m_itemList, static_cast<PAD*>( aItem ) );
break;
}
case PCB_TRACE_T:
if( m_itemMap.find( aItem ) != m_itemMap.end() )
@ -186,6 +197,8 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
return false;
}
markItemNetAsDirty( aItem );
return true;
}

View File

@ -69,7 +69,8 @@ enum FOOTPRINT_ATTR_T
FP_SMD = 0x0002,
FP_EXCLUDE_FROM_POS_FILES = 0x0004,
FP_EXCLUDE_FROM_BOM = 0x0008,
FP_BOARD_ONLY = 0x0010 // Footprint has no corresponding symbol
FP_BOARD_ONLY = 0x0010, // Footprint has no corresponding symbol
FP_JUST_ADDED = 0x0020 // Footprint just added by netlist update
};
class FP_3DMODEL

View File

@ -178,6 +178,12 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewFootprint( COMPONENT* aComponent )
footprint->SetParent( m_board );
footprint->SetPosition( estimateFootprintInsertionPosition() );
// This flag is used to prevent connectivity from considering the footprint during its
// initial build after the footprint is committed, because we're going to immediately start
// a move operation on the footprint and don't want its pads to drive nets onto vias/tracks
// it happens to land on at the initial position.
footprint->SetAttributes( footprint->GetAttributes() | FP_JUST_ADDED );
m_addedFootprints.push_back( footprint );
m_commit.Add( footprint );

View File

@ -114,7 +114,10 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, bool* aR
if( !newFootprints.empty() )
{
for( FOOTPRINT* footprint : newFootprints )
{
footprint->SetAttributes( footprint->GetAttributes() & ~FP_JUST_ADDED );
GetToolManager()->RunAction( PCB_ACTIONS::selectItem, true, footprint );
}
*aRunDragCommand = true;