CADSTAR Sch: Clear symbol of all elements before overwriting with new one

Fixes https://gitlab.com/kicad/code/kicad/-/issues/11378
This commit is contained in:
Roberto Fernandez Bautista 2022-04-12 21:33:52 +01:00
parent 306dfef7e5
commit 85f6ff48e7
1 changed files with 7 additions and 0 deletions

View File

@ -1300,6 +1300,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
SYMDEF_SCM symbol = Library.SymbolDefinitions.at( aSymdefID );
int gateNumber = getKiCadUnitNumberFromGate( aGateID );
// Ensure there are no items on this unit (e.g. if we already previously loaded the symbol from
// the part definition)
std::vector<LIB_ITEM*> drawItems = aSymbol->GetUnitDrawItems( gateNumber, 0 );
for( LIB_ITEM* item : drawItems )
aSymbol->RemoveDrawItem( item );
for( std::pair<FIGURE_ID, FIGURE> figPair : symbol.Figures )
{
FIGURE fig = figPair.second;