Don't arbitrarily close tags that are not open
Fixes https://gitlab.com/kicad/code/kicad/issues/12647
This commit is contained in:
parent
668180f96a
commit
5c974f8cd0
|
@ -793,11 +793,14 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
|
|||
}
|
||||
}
|
||||
|
||||
if( !aSymbol->GetInstanceReferences().empty() )
|
||||
{
|
||||
m_out->Print( aNestLevel + 1, "(instances\n" );
|
||||
|
||||
KIID lastProjectUuid;
|
||||
KIID rootSheetUuid = aSchematic.Root().m_Uuid;
|
||||
SCH_SHEET_LIST fullHierarchy = aSchematic.GetSheets();
|
||||
bool project_open = false;
|
||||
|
||||
for( size_t i = 0; i < aSymbol->GetInstanceReferences().size(); i++ )
|
||||
{
|
||||
|
@ -810,9 +813,12 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
|
|||
&& ( aSymbol->GetInstanceReferences()[i].m_Path[0] == rootSheetUuid )
|
||||
&& !fullHierarchy.GetSheetPathByKIIDPath( aSymbol->GetInstanceReferences()[i].m_Path ) )
|
||||
{
|
||||
if( ( i + 1 == aSymbol->GetInstanceReferences().size() )
|
||||
|| lastProjectUuid != aSymbol->GetInstanceReferences()[i+1].m_Path[0] )
|
||||
if( project_open && ( ( i + 1 == aSymbol->GetInstanceReferences().size() )
|
||||
|| lastProjectUuid != aSymbol->GetInstanceReferences()[i+1].m_Path[0] ) )
|
||||
{
|
||||
m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project`.
|
||||
project_open = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -828,6 +834,7 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
|
|||
|
||||
lastProjectUuid = aSymbol->GetInstanceReferences()[i].m_Path[0];
|
||||
m_out->Print( aNestLevel + 2, "(project %s\n", m_out->Quotew( projectName ).c_str() );
|
||||
project_open = true;
|
||||
}
|
||||
|
||||
wxString path = aSymbol->GetInstanceReferences()[i].m_Path.AsString();
|
||||
|
@ -841,12 +848,17 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
|
|||
m_out->Quotew( aSymbol->GetInstanceReferences()[i].m_Footprint ).c_str() );
|
||||
m_out->Print( aNestLevel + 3, ")\n" );
|
||||
|
||||
if( ( i + 1 == aSymbol->GetInstanceReferences().size() )
|
||||
|| lastProjectUuid != aSymbol->GetInstanceReferences()[i+1].m_Path[0] )
|
||||
if( project_open && ( ( i + 1 == aSymbol->GetInstanceReferences().size() )
|
||||
|| lastProjectUuid != aSymbol->GetInstanceReferences()[i+1].m_Path[0] ) )
|
||||
{
|
||||
m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project`.
|
||||
project_open = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel + 1, ")\n" ); // Closes `instances`.
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" ); // Closes `symbol`.
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue