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
|
* Function Duplicate
|
||||||
* creates a copy of a BOARD_ITEM.
|
* creates a copy of a BOARD_ITEM.
|
||||||
*/
|
*/
|
||||||
BOARD_ITEM* Duplicate() const
|
virtual BOARD_ITEM* Duplicate() const
|
||||||
{
|
{
|
||||||
EDA_ITEM* dupe = Clone();
|
EDA_ITEM* dupe = Clone();
|
||||||
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
||||||
|
|
|
@ -144,10 +144,11 @@ void ARRAY_CREATOR::Invoke()
|
||||||
|
|
||||||
if( this_item->Type() == PCB_MODULE_T )
|
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();
|
{
|
||||||
});
|
aItem->ClearSelected();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
commit.Add( new_item );
|
commit.Add( new_item );
|
||||||
|
|
|
@ -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* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* new_item = NULL;
|
BOARD_ITEM* new_item = NULL;
|
||||||
|
@ -1374,6 +1388,7 @@ BOARD_ITEM* MODULE::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToModule )
|
||||||
case PCB_PAD_T:
|
case PCB_PAD_T:
|
||||||
{
|
{
|
||||||
D_PAD* new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
|
D_PAD* new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
|
||||||
|
const_cast<KIID&>( new_pad->m_Uuid ) = KIID();
|
||||||
|
|
||||||
if( aAddToModule )
|
if( aAddToModule )
|
||||||
m_pads.push_back( new_pad );
|
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:
|
case PCB_MODULE_ZONE_AREA_T:
|
||||||
{
|
{
|
||||||
new_zone = new MODULE_ZONE_CONTAINER( *static_cast<const MODULE_ZONE_CONTAINER*>( aItem ) );
|
new_zone = new MODULE_ZONE_CONTAINER( *static_cast<const MODULE_ZONE_CONTAINER*>( aItem ) );
|
||||||
|
const_cast<KIID&>( new_zone->m_Uuid ) = KIID();
|
||||||
|
|
||||||
if( aAddToModule )
|
if( aAddToModule )
|
||||||
m_fp_zones.push_back( new_zone );
|
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:
|
case PCB_MODULE_TEXT_T:
|
||||||
{
|
{
|
||||||
TEXTE_MODULE* new_text = new TEXTE_MODULE( *static_cast<const TEXTE_MODULE*>( aItem ) );
|
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 )
|
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:
|
case PCB_MODULE_EDGE_T:
|
||||||
{
|
{
|
||||||
EDGE_MODULE* new_edge = new EDGE_MODULE( *static_cast<const EDGE_MODULE*>(aItem) );
|
EDGE_MODULE* new_edge = new EDGE_MODULE( *static_cast<const EDGE_MODULE*>(aItem) );
|
||||||
|
const_cast<KIID&>( new_edge->m_Uuid ) = KIID();
|
||||||
|
|
||||||
if( aAddToModule )
|
if( aAddToModule )
|
||||||
Add( new_edge );
|
Add( new_edge );
|
||||||
|
|
|
@ -566,6 +566,8 @@ public:
|
||||||
int GetPlacementCost90() const { return m_CntRot90; }
|
int GetPlacementCost90() const { return m_CntRot90; }
|
||||||
void SetPlacementCost90( int aCost ) { m_CntRot90 = aCost; }
|
void SetPlacementCost90( int aCost ) { m_CntRot90 = aCost; }
|
||||||
|
|
||||||
|
BOARD_ITEM* Duplicate() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function DuplicateItem
|
* Function DuplicateItem
|
||||||
* Duplicate a given item within the module, optionally adding it to the board
|
* 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
|
// copy constructor to clone the template
|
||||||
MODULE* m = new MODULE( *mi->second );
|
MODULE* m = new MODULE( *mi->second );
|
||||||
|
const_cast<KIID&>( m->m_Uuid ) = KIID();
|
||||||
|
|
||||||
m_board->Add( m, ADD_MODE::APPEND );
|
m_board->Add( m, ADD_MODE::APPEND );
|
||||||
|
|
||||||
// update the nets within the pads of the clone
|
// update the nets within the pads of the clone
|
||||||
|
|
|
@ -821,6 +821,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
||||||
|
|
||||||
// Create the "new" module
|
// Create the "new" module
|
||||||
MODULE* newmodule = new MODULE( *module_in_edit );
|
MODULE* newmodule = new MODULE( *module_in_edit );
|
||||||
|
const_cast<KIID&>( newmodule->m_Uuid ) = KIID();
|
||||||
|
|
||||||
newmodule->SetParent( mainpcb );
|
newmodule->SetParent( mainpcb );
|
||||||
newmodule->SetLink( niluuid );
|
newmodule->SetLink( niluuid );
|
||||||
|
|
||||||
|
|
|
@ -452,6 +452,7 @@ MODULE* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aIn
|
||||||
pad->SetShape( PAD_SHAPE_CIRCLE );
|
pad->SetShape( PAD_SHAPE_CIRCLE );
|
||||||
|
|
||||||
D_PAD* newpad = new D_PAD( *pad );
|
D_PAD* newpad = new D_PAD( *pad );
|
||||||
|
const_cast<KIID&>( newpad->m_Uuid ) = KIID();
|
||||||
|
|
||||||
module->Add( newpad );
|
module->Add( newpad );
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,7 @@ void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter )
|
||||||
continue; // Module does not exist in any library.
|
continue; // Module does not exist in any library.
|
||||||
|
|
||||||
module = new MODULE( *module );
|
module = new MODULE( *module );
|
||||||
|
const_cast<KIID&>( module->m_Uuid ) = KIID();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( module )
|
if( module )
|
||||||
|
|
|
@ -182,10 +182,10 @@ void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem )
|
||||||
|
|
||||||
if( lastItem->Type() == PCB_MODULE_T )
|
if( lastItem->Type() == PCB_MODULE_T )
|
||||||
{
|
{
|
||||||
static_cast<MODULE*>( lastItem )->RunOnChildren( [&] ( BOARD_ITEM* child )
|
static_cast<MODULE*>( lastItem )->RunOnChildren( [&]( BOARD_ITEM* child )
|
||||||
{
|
{
|
||||||
child->ClearBrightened();
|
child->ClearBrightened();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCanvas()->GetView()->Update( lastItem );
|
GetCanvas()->GetView()->Update( lastItem );
|
||||||
|
@ -199,10 +199,10 @@ void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem )
|
||||||
|
|
||||||
if( aItem->Type() == PCB_MODULE_T )
|
if( aItem->Type() == PCB_MODULE_T )
|
||||||
{
|
{
|
||||||
static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* child )
|
static_cast<MODULE*>( aItem )->RunOnChildren( [&]( BOARD_ITEM* child )
|
||||||
{
|
{
|
||||||
child->SetBrightened();
|
child->SetBrightened();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCanvas()->GetView()->Update( aItem );
|
GetCanvas()->GetView()->Update( aItem );
|
||||||
|
|
|
@ -1944,21 +1944,22 @@ void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION*
|
||||||
// highlight all the parts that make the module, not the module itself
|
// highlight all the parts that make the module, not the module itself
|
||||||
if( aItem->Type() == PCB_MODULE_T )
|
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();
|
if( aMode == SELECTED )
|
||||||
else if( aMode == BRIGHTENED )
|
item->SetSelected();
|
||||||
{
|
else if( aMode == BRIGHTENED )
|
||||||
item->SetBrightened();
|
{
|
||||||
|
item->SetBrightened();
|
||||||
|
|
||||||
if( aGroup )
|
if( aGroup )
|
||||||
aGroup->Add( item );
|
aGroup->Add( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aGroup )
|
if( aGroup )
|
||||||
view()->Hide( item, true );
|
view()->Hide( item, true );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
view()->Update( aItem );
|
view()->Update( aItem );
|
||||||
|
@ -1989,23 +1990,24 @@ void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION
|
||||||
// highlight all the parts that make the module, not the module itself
|
// highlight all the parts that make the module, not the module itself
|
||||||
if( aItem->Type() == PCB_MODULE_T )
|
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();
|
if( aMode == SELECTED )
|
||||||
else if( aMode == BRIGHTENED )
|
item->ClearSelected();
|
||||||
item->ClearBrightened();
|
else if( aMode == BRIGHTENED )
|
||||||
|
item->ClearBrightened();
|
||||||
|
|
||||||
// N.B. if we clear the selection flag for sub-elements, we need to also
|
// N.B. if we clear the selection flag for sub-elements, we need to also
|
||||||
// remove the element from the selection group (if it exists)
|
// remove the element from the selection group (if it exists)
|
||||||
if( aGroup )
|
if( aGroup )
|
||||||
{
|
{
|
||||||
aGroup->Remove( item );
|
aGroup->Remove( item );
|
||||||
|
|
||||||
view()->Hide( item, false );
|
view()->Hide( item, false );
|
||||||
view()->Update( item );
|
view()->Update( item );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
view()->Update( aItem );
|
view()->Update( aItem );
|
||||||
|
|
Loading…
Reference in New Issue