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:
parent
7a4325e610
commit
12861345d3
pcbnew
@ -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" ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user