Fields: synchronize empty fields between sch<->pcb

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/15341
This commit is contained in:
Mike Williams 2023-08-07 09:15:45 -04:00
parent 778213ba8f
commit 25de3e6b33
1 changed files with 10 additions and 17 deletions

View File

@ -162,13 +162,12 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
{ {
const SCH_FIELD& f = symbol2->GetFields()[ ii ]; const SCH_FIELD& f = symbol2->GetFields()[ ii ];
if( f.GetText().size() if( unit < minUnit || userFields.count( f.GetName() ) == 0 )
&& ( unit < minUnit || userFields.count( f.GetName() ) == 0 ) )
{ {
if( m_resolveTextVars ) if( m_resolveTextVars )
userFields[ f.GetName() ] = f.GetShownText( aSheet, false ); userFields[f.GetName()] = f.GetShownText( aSheet, false );
else else
userFields[ f.GetName() ] = f.GetText(); userFields[f.GetName()] = f.GetText();
} }
} }
@ -197,13 +196,10 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
{ {
const SCH_FIELD& f = aSymbol->GetFields()[ ii ]; const SCH_FIELD& f = aSymbol->GetFields()[ ii ];
if( f.GetText().size() ) if( m_resolveTextVars )
{ userFields[f.GetName()] = f.GetShownText( aSheet, false );
if( m_resolveTextVars ) else
userFields[ f.GetName() ] = f.GetShownText( aSheet, false ); userFields[f.GetName()] = f.GetText();
else
userFields[ f.GetName() ] = f.GetText();
}
} }
} }
@ -614,12 +610,9 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
for( const LIB_FIELD* field : fieldList ) for( const LIB_FIELD* field : fieldList )
{ {
if( !field->GetText().IsEmpty() ) XNODE* xfield;
{ xfields->AddChild( xfield = node( wxT( "field" ), field->GetText() ) );
XNODE* xfield; xfield->AddAttribute( wxT( "name" ), field->GetCanonicalName() );
xfields->AddChild( xfield = node( wxT( "field" ), field->GetText() ) );
xfield->AddAttribute( wxT( "name" ), field->GetCanonicalName() );
}
} }
//----- show the pins here ------------------------------------ //----- show the pins here ------------------------------------