Fix a bunch of usages of copy ctor that really meant duplicate.
In particular, "duplicate" means "with a new KIID". Fixes https://gitlab.com/kicad/code/kicad/issues/5127
This commit is contained in:
parent
827138f6b4
commit
692aeff334
|
@ -207,7 +207,7 @@ public:
|
|||
* Function Duplicate
|
||||
* creates a copy of a BOARD_ITEM.
|
||||
*/
|
||||
BOARD_ITEM* Duplicate() const
|
||||
virtual BOARD_ITEM* Duplicate() const
|
||||
{
|
||||
EDA_ITEM* dupe = Clone();
|
||||
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
||||
|
|
|
@ -144,7 +144,8 @@ void ARRAY_CREATOR::Invoke()
|
|||
|
||||
if( this_item->Type() == PCB_MODULE_T )
|
||||
{
|
||||
static_cast<MODULE*>( this_item )->RunOnChildren( [&] ( BOARD_ITEM* aItem )
|
||||
static_cast<MODULE*>( this_item )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* aItem )
|
||||
{
|
||||
aItem->ClearSelected();
|
||||
});
|
||||
|
|
|
@ -1364,6 +1364,20 @@ void MODULE::SetOrientation( double newangle )
|
|||
}
|
||||
|
||||
|
||||
BOARD_ITEM* MODULE::Duplicate() const
|
||||
{
|
||||
MODULE* dupe = (MODULE*) Clone();
|
||||
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
||||
|
||||
dupe->RunOnChildren( [&]( BOARD_ITEM* child )
|
||||
{
|
||||
const_cast<KIID&>( child->m_Uuid ) = KIID();
|
||||
});
|
||||
|
||||
return static_cast<BOARD_ITEM*>( dupe );
|
||||
}
|
||||
|
||||
|
||||
BOARD_ITEM* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
||||
{
|
||||
BOARD_ITEM* new_item = NULL;
|
||||
|
@ -1374,6 +1388,7 @@ BOARD_ITEM* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
|||
case PCB_PAD_T:
|
||||
{
|
||||
D_PAD* new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
|
||||
const_cast<KIID&>( new_pad->m_Uuid ) = KIID();
|
||||
|
||||
if( aAddToModule )
|
||||
m_pads.push_back( new_pad );
|
||||
|
@ -1385,6 +1400,7 @@ BOARD_ITEM* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
|||
case PCB_MODULE_ZONE_AREA_T:
|
||||
{
|
||||
new_zone = new MODULE_ZONE_CONTAINER( *static_cast<const MODULE_ZONE_CONTAINER*>( aItem ) );
|
||||
const_cast<KIID&>( new_zone->m_Uuid ) = KIID();
|
||||
|
||||
if( aAddToModule )
|
||||
m_fp_zones.push_back( new_zone );
|
||||
|
@ -1396,6 +1412,7 @@ BOARD_ITEM* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
|||
case PCB_MODULE_TEXT_T:
|
||||
{
|
||||
TEXTE_MODULE* new_text = new TEXTE_MODULE( *static_cast<const TEXTE_MODULE*>( aItem ) );
|
||||
const_cast<KIID&>( new_text->m_Uuid ) = KIID();
|
||||
|
||||
if( new_text->GetType() == TEXTE_MODULE::TEXT_is_REFERENCE )
|
||||
{
|
||||
|
@ -1419,6 +1436,7 @@ BOARD_ITEM* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
|||
case PCB_MODULE_EDGE_T:
|
||||
{
|
||||
EDGE_MODULE* new_edge = new EDGE_MODULE( *static_cast<const EDGE_MODULE*>(aItem) );
|
||||
const_cast<KIID&>( new_edge->m_Uuid ) = KIID();
|
||||
|
||||
if( aAddToModule )
|
||||
Add( new_edge );
|
||||
|
|
|
@ -566,6 +566,8 @@ public:
|
|||
int GetPlacementCost90() const { return m_CntRot90; }
|
||||
void SetPlacementCost90( int aCost ) { m_CntRot90 = aCost; }
|
||||
|
||||
BOARD_ITEM* Duplicate() const override;
|
||||
|
||||
/**
|
||||
* Function DuplicateItem
|
||||
* Duplicate a given item within the module, optionally adding it to the board
|
||||
|
|
|
@ -1047,6 +1047,8 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
|
||||
// copy constructor to clone the template
|
||||
MODULE* m = new MODULE( *mi->second );
|
||||
const_cast<KIID&>( m->m_Uuid ) = KIID();
|
||||
|
||||
m_board->Add( m, ADD_MODE::APPEND );
|
||||
|
||||
// update the nets within the pads of the clone
|
||||
|
|
|
@ -821,6 +821,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
|||
|
||||
// Create the "new" module
|
||||
MODULE* newmodule = new MODULE( *module_in_edit );
|
||||
const_cast<KIID&>( newmodule->m_Uuid ) = KIID();
|
||||
|
||||
newmodule->SetParent( mainpcb );
|
||||
newmodule->SetLink( niluuid );
|
||||
|
||||
|
|
|
@ -452,6 +452,7 @@ MODULE* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aIn
|
|||
pad->SetShape( PAD_SHAPE_CIRCLE );
|
||||
|
||||
D_PAD* newpad = new D_PAD( *pad );
|
||||
const_cast<KIID&>( newpad->m_Uuid ) = KIID();
|
||||
|
||||
module->Add( newpad );
|
||||
|
||||
|
|
|
@ -238,6 +238,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter )
|
|||
continue; // Module does not exist in any library.
|
||||
|
||||
module = new MODULE( *module );
|
||||
const_cast<KIID&>( module->m_Uuid ) = KIID();
|
||||
}
|
||||
|
||||
if( module )
|
||||
|
|
|
@ -1944,7 +1944,8 @@ void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION*
|
|||
// highlight all the parts that make the module, not the module itself
|
||||
if( aItem->Type() == PCB_MODULE_T )
|
||||
{
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* item )
|
||||
{
|
||||
if( aMode == SELECTED )
|
||||
item->SetSelected();
|
||||
|
@ -1989,7 +1990,8 @@ void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION
|
|||
// highlight all the parts that make the module, not the module itself
|
||||
if( aItem->Type() == PCB_MODULE_T )
|
||||
{
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* item )
|
||||
{
|
||||
if( aMode == SELECTED )
|
||||
item->ClearSelected();
|
||||
|
|
Loading…
Reference in New Issue