Ignore empty field-name-templates.

Fixes https://gitlab.com/kicad/code/kicad/issues/14552
This commit is contained in:
Jeff Young 2023-04-18 13:45:53 +01:00
parent 955774a91a
commit 4f9e754a51
2 changed files with 10 additions and 3 deletions

View File

@ -129,7 +129,10 @@ void TEMPLATES::Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) cons
const TEMPLATE_FIELDNAMES& source = aGlobal ? m_globals : m_project; const TEMPLATE_FIELDNAMES& source = aGlobal ? m_globals : m_project;
for( const TEMPLATE_FIELDNAME& temp : source ) for( const TEMPLATE_FIELDNAME& temp : source )
{
if( !temp.m_Name.IsEmpty() )
temp.Format( out, nestLevel+1 ); temp.Format( out, nestLevel+1 );
}
out->Print( 0, ")\n" ); out->Print( 0, ")\n" );
} }
@ -162,6 +165,7 @@ void TEMPLATES::parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal )
field.Parse( in ); field.Parse( in );
// add the field // add the field
if( !field.m_Name.IsEmpty() )
AddTemplateFieldName( field, aGlobal ); AddTemplateFieldName( field, aGlobal );
} }
break; break;

View File

@ -185,7 +185,10 @@ bool PANEL_TEMPLATE_FIELDNAMES::TransferDataFromWindow()
m_templateMgr->DeleteAllFieldNameTemplates( m_global ); m_templateMgr->DeleteAllFieldNameTemplates( m_global );
for( const TEMPLATE_FIELDNAME& field : m_fields ) for( const TEMPLATE_FIELDNAME& field : m_fields )
{
if( !field.m_Name.IsEmpty() )
m_templateMgr->AddTemplateFieldName( field, m_global ); m_templateMgr->AddTemplateFieldName( field, m_global );
}
if( m_global ) if( m_global )
{ {