Eeschema: fix datasheet field bug loading old symbol libraries.

This only applies to the root symbol when the datasheet field is not
empty and the datasheet for root symbol alias in the document file is
empty.  Use the root symbol datasheet field value when adding a new
symbol that meets this criteria.

https://bugs.launchpad.net/kicad/+bug/1830083

Fixes lp:1830083

(cherry picked from commit 300f5cb082)
This commit is contained in:
Wayne Stambaugh 2019-05-22 19:18:24 -04:00
parent 2a932a2176
commit 6afc572eae
1 changed files with 15 additions and 0 deletions

View File

@ -980,6 +980,7 @@ void SCH_COMPONENT::UpdateFields( bool aResetStyle, bool aResetRef )
{
if( PART_SPTR part = m_part.lock() )
{
wxString symbolName;
LIB_FIELDS fields;
part->GetFields( fields );
@ -1000,6 +1001,7 @@ void SCH_COMPONENT::UpdateFields( bool aResetStyle, bool aResetRef )
if( idx == REFERENCE && !aResetRef )
continue;
if( (unsigned) idx < MANDATORY_FIELDS )
schField = GetField( idx );
else
@ -1018,11 +1020,24 @@ void SCH_COMPONENT::UpdateFields( bool aResetStyle, bool aResetRef )
}
if( idx == VALUE )
{
schField->SetText( m_lib_id.GetLibItemName() ); // fetch alias-specific value
symbolName = m_lib_id.GetLibItemName();
}
else if( idx == DATASHEET )
{
schField->SetText( GetDatasheet() ); // fetch alias-specific value
// Some older libraries may be broken and the alias datasheet information
// in the document file for the root part may have been dropped. This only
// happens for the root part.
if( schField->GetText().IsEmpty() && symbolName == part->GetName() )
schField->SetText( part->GetField( DATASHEET )->GetText() );
}
else
{
schField->SetText( field.GetText() );
}
}
}
}