Fix Update Fields to use alias values.

Fixes: lp:1778826
* https://bugs.launchpad.net/kicad/+bug/1778826

(cherry picked from commit 1de2a80)
This commit is contained in:
Jeff Young 2018-06-26 18:50:58 +01:00
parent 49ea6e1670
commit 5db4a85430
2 changed files with 14 additions and 2 deletions

View File

@ -148,6 +148,8 @@ void DIALOG_UPDATE_FIELDS::updateFields( SCH_COMPONENT* aComponent )
if( libPart == nullptr ) // the symbol is not found in lib: cannot update fields
return;
LIB_ALIAS* alias = m_frame->GetLibAlias( aComponent->GetLibId() );
aComponent->GetFields( oldFields, false );
for( auto compField : oldFields )
@ -181,10 +183,20 @@ void DIALOG_UPDATE_FIELDS::updateFields( SCH_COMPONENT* aComponent )
field = &newFields.back();
}
wxString fieldValue = libField->GetText();
if( alias )
{
if( partField == TEMPLATE_FIELDNAME::GetDefaultFieldName( VALUE ) )
fieldValue = alias->GetName();
else if( partField == TEMPLATE_FIELDNAME::GetDefaultFieldName( DATASHEET ) )
fieldValue = alias->GetDocFileName();
}
// If the library field is empty an update would clear an existing entry.
// Check if this is the desired behavior.
if( !libField->GetText().empty() || m_resetEmpty->IsChecked() )
field->SetText( libField->GetText() );
field->SetText( fieldValue );
if( m_resetVisibility->IsChecked() )
field->SetVisible( libField->IsVisible() );

View File

@ -522,7 +522,7 @@ void prepareEditMenu( wxMenu* aParentMenu )
// Update field values
AddMenuItem( aParentMenu, ID_UPDATE_FIELDS,
_( "Update Field Values..." ),
_( "Update Fields from Library..." ),
_( "Sets symbol fields to original library values" ),
KiBitmap( update_fields_xpm ) );
}