CADSTAR Archive Importer: Fix duplicate KIID for loaded elements
Don't use clone to copy an EDA_ITEM. Use Duplicate(). Even if you give the clone a new KIID, all its children will still be clones. Create Duplicate() in LIB_PART
This commit is contained in:
parent
d2fbe12cfd
commit
0691e942f4
|
@ -144,6 +144,21 @@ public:
|
||||||
|
|
||||||
PART_SPTR SharedPtr() { return m_me; }
|
PART_SPTR SharedPtr() { return m_me; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Duplicate
|
||||||
|
* Creates a copy of a LIB_PART and assigns unique KIIDs to the copy and its children
|
||||||
|
*/
|
||||||
|
virtual LIB_PART* Duplicate() const
|
||||||
|
{
|
||||||
|
LIB_PART* dupe = new LIB_PART( *this, m_library );
|
||||||
|
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
||||||
|
|
||||||
|
for( LIB_ITEM& item : dupe->m_drawings )
|
||||||
|
const_cast<KIID&>( item.m_Uuid ) = KIID();
|
||||||
|
|
||||||
|
return dupe;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// We create a different set parent function for this class, so we hide
|
// We create a different set parent function for this class, so we hide
|
||||||
// the inherited one.
|
// the inherited one.
|
||||||
|
|
|
@ -1007,7 +1007,7 @@ SCH_COMPONENT* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(
|
||||||
component->SetOrientation( compOrientation );
|
component->SetOrientation( compOrientation );
|
||||||
LIB_ID libId( mLibraryFileName.GetName(), aKiCadPart->GetName() );
|
LIB_ID libId( mLibraryFileName.GetName(), aKiCadPart->GetName() );
|
||||||
component->SetLibId( libId );
|
component->SetLibId( libId );
|
||||||
component->SetLibSymbol( new LIB_PART( *aKiCadPart ) );
|
component->SetLibSymbol( aKiCadPart->Duplicate() );
|
||||||
component->SetUnit( getKiCadUnitNumberFromGate( aCadstarSymbol.GateID ) );
|
component->SetUnit( getKiCadUnitNumberFromGate( aCadstarSymbol.GateID ) );
|
||||||
|
|
||||||
if( mSheetMap.find( aCadstarSymbol.LayerID ) == mSheetMap.end() )
|
if( mSheetMap.find( aCadstarSymbol.LayerID ) == mSheetMap.end() )
|
||||||
|
|
|
@ -1209,9 +1209,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
|
||||||
|
|
||||||
FOOTPRINT* libFootprint = fpIter->second;
|
FOOTPRINT* libFootprint = fpIter->second;
|
||||||
|
|
||||||
// copy constructor to clone the footprint from the library
|
// Use Duplicate() to ensure unique KIID for all objects
|
||||||
FOOTPRINT* footprint = new FOOTPRINT( *libFootprint );
|
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( libFootprint->Duplicate() );
|
||||||
const_cast<KIID&>( footprint->m_Uuid ) = KIID();
|
|
||||||
|
|
||||||
mBoard->Add( footprint, ADD_MODE::APPEND );
|
mBoard->Add( footprint, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
@ -1885,7 +1884,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
|
||||||
for( PCB_LAYER_ID layer : layers )
|
for( PCB_LAYER_ID layer : layers )
|
||||||
{
|
{
|
||||||
txt->SetLayer( layer );
|
txt->SetLayer( layer );
|
||||||
newtxt = new PCB_TEXT( *txt );
|
newtxt = static_cast<PCB_TEXT*>( txt->Duplicate() );
|
||||||
mBoard->Add( newtxt, ADD_MODE::APPEND );
|
mBoard->Add( newtxt, ADD_MODE::APPEND );
|
||||||
|
|
||||||
if( !aCadstarGroupID.IsEmpty() )
|
if( !aCadstarGroupID.IsEmpty() )
|
||||||
|
@ -2383,7 +2382,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
|
||||||
if( !aFootprint->Value().GetText().IsEmpty() )
|
if( !aFootprint->Value().GetText().IsEmpty() )
|
||||||
{
|
{
|
||||||
//copy the object
|
//copy the object
|
||||||
aFootprint->Add( new FP_TEXT( aFootprint->Value() ) );
|
aFootprint->Add( aFootprint->Value().Duplicate() );
|
||||||
}
|
}
|
||||||
|
|
||||||
aFootprint->SetValue( aAttributeValue );
|
aFootprint->SetValue( aAttributeValue );
|
||||||
|
|
Loading…
Reference in New Issue