Fp editor: fix some crashes when trying to duplicate referece or value texts.
Fixes #8990 https://gitlab.com/kicad/code/kicad/issues/8990
This commit is contained in:
parent
a9aae9b3f7
commit
82849eda42
|
@ -516,7 +516,7 @@ void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
|
|||
{
|
||||
case PCB_FP_TEXT_T:
|
||||
// Only user text can be added this way.
|
||||
assert( static_cast<FP_TEXT*>( aBoardItem )->GetType() == FP_TEXT::TEXT_is_DIVERS );
|
||||
wxASSERT( static_cast<FP_TEXT*>( aBoardItem )->GetType() == FP_TEXT::TEXT_is_DIVERS );
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case PCB_FP_SHAPE_T:
|
||||
|
@ -2048,7 +2048,7 @@ void FOOTPRINT::BuildPolyCourtyards( OUTLINE_ERROR_HANDLER* aErrorHandler )
|
|||
|
||||
void FOOTPRINT::SwapData( BOARD_ITEM* aImage )
|
||||
{
|
||||
assert( aImage->Type() == PCB_FOOTPRINT_T );
|
||||
wxASSERT( aImage->Type() == PCB_FOOTPRINT_T );
|
||||
|
||||
std::swap( *((FOOTPRINT*) this), *((FOOTPRINT*) aImage) );
|
||||
}
|
||||
|
|
|
@ -126,17 +126,38 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
|||
// correct
|
||||
partialFootprint.Add( clone );
|
||||
|
||||
// A list of not added items, when adding items to the footprint
|
||||
// some FP_TEXT (reference and value) cannot be added to the footprint
|
||||
std::vector<BOARD_ITEM*> skipped_items;
|
||||
|
||||
if( group )
|
||||
{
|
||||
static_cast<PCB_GROUP*>( clone )->RunOnDescendants(
|
||||
[&]( BOARD_ITEM* descendant )
|
||||
{
|
||||
partialFootprint.Add( descendant );
|
||||
// One cannot add a text reference or value to a given footprint:
|
||||
// only one is allowed. So add only FP_TEXT::TEXT_is_DIVERS
|
||||
bool can_add = true;
|
||||
|
||||
if( const FP_TEXT* text = dyn_cast<const FP_TEXT*>( descendant ) )
|
||||
{
|
||||
if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
|
||||
can_add = false;
|
||||
}
|
||||
|
||||
if( can_add )
|
||||
partialFootprint.Add( descendant );
|
||||
else
|
||||
skipped_items.push_back( descendant );
|
||||
} );
|
||||
}
|
||||
|
||||
// locate the reference point at (0, 0) in the copied items
|
||||
clone->Move( (wxPoint) -refPoint );
|
||||
|
||||
// Now delete items, duplicated but not added:
|
||||
for( BOARD_ITEM* skp_item : skipped_items )
|
||||
delete skp_item;
|
||||
}
|
||||
|
||||
// Set the new relative internal local coordinates of copied items
|
||||
|
|
|
@ -992,8 +992,8 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
|||
// Select the items that should be selected
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &itemsToSel );
|
||||
|
||||
// Reannotate duplicate footprints
|
||||
if( aReannotateDuplicates )
|
||||
// Reannotate duplicate footprints (make sense only in board editor )
|
||||
if( aReannotateDuplicates && m_frame->IsType( FRAME_PCB_EDITOR ) )
|
||||
m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
|
||||
|
||||
for( BOARD_ITEM* item : aItems )
|
||||
|
|
Loading…
Reference in New Issue