Make sure migrated aliases get hooked up to migrated parents.

Fixes https://gitlab.com/kicad/code/kicad/issues/7322
This commit is contained in:
Jeff Young 2021-02-16 12:48:18 +00:00
parent 572ba8984a
commit a1f510ef6a
1 changed files with 25 additions and 1 deletions

View File

@ -774,6 +774,7 @@ bool PANEL_SYM_LIB_TABLE::convertLibrary( const wxString& aLibrary, const wxStri
SCH_PLUGIN::SCH_PLUGIN_RELEASER kicadPI( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
std::vector<LIB_PART*> parts;
std::vector<LIB_PART*> newParts;
std::map<LIB_PART*, LIB_PART*> partMap;
try
{
@ -788,8 +789,31 @@ bool PANEL_SYM_LIB_TABLE::convertLibrary( const wxString& aLibrary, const wxStri
legacyPI->EnumerateSymbolLib( parts, legacyFilepath );
// Copy non-aliases first so we can build a map from parts to newParts
for( LIB_PART* part : parts )
kicadPI->SaveSymbol( newFilepath, new LIB_PART( *part ) );
{
if( part->IsAlias() )
continue;
newParts.push_back( new LIB_PART( *part ) );
partMap[part] = newParts.back();
}
// Now do the aliases using the map to hook them up to their newPart parents
for( LIB_PART* part : parts )
{
if( !part->IsAlias() )
continue;
newParts.push_back( new LIB_PART( *part ) );
newParts.back()->SetParent( partMap[ part->GetParent().lock().get() ] );
}
// Finally write out newParts
for( LIB_PART* part : newParts )
{
kicadPI->SaveSymbol( newFilepath, part );
}
}
catch( ... )
{