Ensure nets are referenced to main board
We set new elements to the temporary board's netlist. These need to be
updated when moving the fooprint to the main board
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17242
(cherry picked from commit 54efd32f7a
)
This commit is contained in:
parent
828f32649f
commit
522f1c7bea
|
@ -925,6 +925,28 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
|||
fixUuid( const_cast<KIID&>( aChild->m_Uuid ) );
|
||||
} );
|
||||
|
||||
// Right now, we only show the "Unconnected" net in the footprint editor, but this is still
|
||||
// referenced in the footprint. So we need to update the net pointers in the footprint to
|
||||
// point to the nets in the main board.
|
||||
newFootprint->RunOnDescendants(
|
||||
[&]( BOARD_ITEM* aChild )
|
||||
{
|
||||
if( BOARD_CONNECTED_ITEM* conn = dynamic_cast<BOARD_CONNECTED_ITEM*>( aChild ) )
|
||||
{
|
||||
NETINFO_ITEM* net = conn->GetNet();
|
||||
auto& netmap = mainpcb->GetNetInfo().NetsByName();
|
||||
|
||||
if( net )
|
||||
{
|
||||
auto it = netmap.find( net->GetNetname() );
|
||||
|
||||
if( it != netmap.end() )
|
||||
conn->SetNet( it->second );
|
||||
}
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
BOARD_DESIGN_SETTINGS& bds = m_pcb->GetDesignSettings();
|
||||
|
||||
newFootprint->ApplyDefaultSettings( *m_pcb, bds.m_StyleFPFields, bds.m_StyleFPText,
|
||||
|
|
Loading…
Reference in New Issue