From 5db4a85430cea998574155939e2281a035bd4d5e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 26 Jun 2018 18:50:58 +0100 Subject: [PATCH] Fix Update Fields to use alias values. Fixes: lp:1778826 * https://bugs.launchpad.net/kicad/+bug/1778826 (cherry picked from commit 1de2a80) --- eeschema/dialogs/dialog_update_fields.cpp | 14 +++++++++++++- eeschema/menubar.cpp | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/eeschema/dialogs/dialog_update_fields.cpp b/eeschema/dialogs/dialog_update_fields.cpp index b7e8c7c943..983607e024 100644 --- a/eeschema/dialogs/dialog_update_fields.cpp +++ b/eeschema/dialogs/dialog_update_fields.cpp @@ -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() ); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index b43f874baf..208bb8d220 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -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 ) ); }