Fix legacy schematic symbol instance data bug.
This commit is contained in:
parent
12a55f20d3
commit
6f90a63381
|
@ -1352,20 +1352,23 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
|
|||
{
|
||||
KIID_PATH path;
|
||||
path.push_back( m_rootSheet->GetScreen()->GetUuid() );
|
||||
symbol->AddHierarchicalReference( path,
|
||||
symbol->GetField( REFERENCE_FIELD )->GetText(),
|
||||
symbol->GetUnit(),
|
||||
symbol->GetField( VALUE_FIELD )->GetText(),
|
||||
symbol->GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
|
||||
SYMBOL_INSTANCE_REFERENCE instance;
|
||||
instance.m_Path = path;
|
||||
instance.m_Reference = symbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
instance.m_Unit = symbol->GetUnit();
|
||||
instance.m_Value = symbol->GetField( VALUE_FIELD )->GetText();
|
||||
instance.m_Footprint = symbol->GetField( FOOTPRINT_FIELD )->GetText();
|
||||
symbol->AddHierarchicalReference( instance );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( const SYMBOL_INSTANCE_REFERENCE& instance : symbol->GetInstanceReferences() )
|
||||
{
|
||||
symbol->AddHierarchicalReference( instance.m_Path, instance.m_Reference,
|
||||
instance.m_Unit,
|
||||
symbol->GetField( VALUE_FIELD )->GetText(),
|
||||
symbol->GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
SYMBOL_INSTANCE_REFERENCE tmpInstance = instance;
|
||||
tmpInstance.m_Value = symbol->GetField( VALUE_FIELD )->GetText();
|
||||
tmpInstance.m_Footprint = symbol->GetField( FOOTPRINT_FIELD )->GetText();
|
||||
symbol->AddHierarchicalReference( tmpInstance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,23 +588,34 @@ void SCH_SYMBOL::AddHierarchicalReference( const KIID_PATH& aPath, const wxStrin
|
|||
|
||||
void SCH_SYMBOL::AddHierarchicalReference( const SYMBOL_INSTANCE_REFERENCE& aInstance )
|
||||
{
|
||||
// Search for an existing path and remove it if found (should not occur)
|
||||
for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
|
||||
KIID_PATH searchPath( aInstance.m_Path );
|
||||
|
||||
std::vector<SYMBOL_INSTANCE_REFERENCE>::iterator resultIt;
|
||||
|
||||
do
|
||||
{
|
||||
if( m_instanceReferences[ii].m_Path == aInstance.m_Path )
|
||||
resultIt = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
|
||||
[searchPath]( const auto& it )
|
||||
{
|
||||
return it.m_Path == searchPath;
|
||||
} );
|
||||
|
||||
if( resultIt != m_instanceReferences.end() )
|
||||
{
|
||||
wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
|
||||
" sheet path %s\n"
|
||||
" reference %s, unit %d from symbol %s.",
|
||||
aInstance.m_Path.AsString(),
|
||||
m_instanceReferences[ii].m_Reference,
|
||||
m_instanceReferences[ii].m_Unit,
|
||||
m_Uuid.AsString() );
|
||||
" sheet path %s\n"
|
||||
" reference %s, unit %d from symbol %s.",
|
||||
aInstance.m_Path.AsString(),
|
||||
resultIt->m_Reference,
|
||||
resultIt->m_Unit,
|
||||
m_Uuid.AsString() );
|
||||
|
||||
m_instanceReferences.erase( m_instanceReferences.begin() + ii );
|
||||
ii--;
|
||||
// Instance data should be unique by path. Double check just in case there was
|
||||
// some buggy code in the past.
|
||||
resultIt = m_instanceReferences.erase( resultIt );
|
||||
}
|
||||
}
|
||||
while( resultIt != m_instanceReferences.end() );
|
||||
|
||||
SYMBOL_INSTANCE_REFERENCE instance = aInstance;
|
||||
|
||||
|
|
Loading…
Reference in New Issue