7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-07 22:05:32 +00:00

API: Brute-force fix for footprint modifications

This commit is contained in:
Jon Evans 2025-03-29 23:53:37 -04:00
parent 7a4325e610
commit 12861345d3
2 changed files with 17 additions and 10 deletions

View File

@ -477,19 +477,23 @@ HANDLER_RESULT<ItemRequestStatus> API_HANDLER_PCB::handleCreateUpdateItemsIntern
else
{
BOARD_ITEM* boardItem = *optItem;
commit->Modify( boardItem );
// Normally this is done by the footprint methods SetPosition, SetOrientation, etc
// Since the API is just using the assignment operator, we need to wipe out all the
// caches so that they will be rebuilt with any changes to the geometry made by the API
// Footprints can't be modified by CopyFrom at the moment because the commit system
// doesn't currently know what to do with a footprint that has had its children
// replaced with other children; which results in things like the view not having its
// cached geometry for footprint children updated when you move a footprint around.
if( boardItem->Type() == PCB_FOOTPRINT_T )
{
auto boardFp = static_cast<FOOTPRINT*>( boardItem );
boardFp->InvalidateGeometryCaches();
commit->Remove( boardItem );
item->Serialize( newItem );
commit->Add( item.release() );
}
else
{
commit->Modify( boardItem );
boardItem->CopyFrom( item.get() );
boardItem->Serialize( newItem );
}
boardItem->CopyFrom( item.get() );
boardItem->Serialize( newItem );
}
aItemHandler( status, newItem );
@ -498,7 +502,7 @@ HANDLER_RESULT<ItemRequestStatus> API_HANDLER_PCB::handleCreateUpdateItemsIntern
if( !m_activeClients.count( aClientName ) )
{
pushCurrentCommit( aClientName, aCreate ? _( "Created items via API" )
: _( "Added items via API" ) );
: _( "Modified items via API" ) );
}

View File

@ -952,6 +952,9 @@ void FOOTPRINT::CopyFrom( const BOARD_ITEM* aOther )
{
wxCHECK( aOther && aOther->Type() == PCB_FOOTPRINT_T, /* void */ );
*this = *static_cast<const FOOTPRINT*>( aOther );
for( PAD* pad : m_pads )
pad->SetDirty();
}