Fix bad field names when ID == -1.

Fixes https://gitlab.com/kicad/code/kicad/issues/10548
This commit is contained in:
Jeff Young 2022-02-03 12:38:17 +00:00
parent 7ed569058c
commit 3d0b03515d
1 changed files with 2 additions and 2 deletions

View File

@ -788,7 +788,7 @@ wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
{ {
if( m_id < MANDATORY_FIELDS ) if( m_id >= 0 && m_id < MANDATORY_FIELDS )
return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id );
else if( m_name.IsEmpty() && aUseDefaultName ) else if( m_name.IsEmpty() && aUseDefaultName )
return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id );
@ -797,7 +797,7 @@ wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
} }
else if( m_parent && m_parent->Type() == SCH_SHEET_T ) else if( m_parent && m_parent->Type() == SCH_SHEET_T )
{ {
if( m_id < SHEET_MANDATORY_FIELDS ) if( m_id >= 0 && m_id < SHEET_MANDATORY_FIELDS )
return SCH_SHEET::GetDefaultFieldName( m_id ); return SCH_SHEET::GetDefaultFieldName( m_id );
else if( m_name.IsEmpty() && aUseDefaultName ) else if( m_name.IsEmpty() && aUseDefaultName )
return SCH_SHEET::GetDefaultFieldName( m_id ); return SCH_SHEET::GetDefaultFieldName( m_id );