From a6b36adb32cc1da2e2a0e4e3b4ef30e31e59ad32 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 15 Aug 2019 17:01:02 +0100 Subject: [PATCH] Keep value in sync with libId when they match. Fixes: lp:1797482 * https://bugs.launchpad.net/kicad/+bug/1797482 --- eeschema/dialogs/dialog_edit_components_libid.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index 94c578fa8b..cb59f603b0 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -235,7 +235,7 @@ GRIDCELL_AUTOWRAP_STRINGRENDERER::BreakWord(wxDC& dc, } -#define GRID_CELL_MARGIN 3 +#define GRID_CELL_MARGIN 4 int GRIDCELL_AUTOWRAP_STRINGRENDERER::GetHeight( wxDC& aDC, wxGrid* aGrid, int aRow, int aCol ) { @@ -246,7 +246,7 @@ int GRIDCELL_AUTOWRAP_STRINGRENDERER::GetHeight( wxDC& aDC, wxGrid* aGrid, int a rect.SetWidth( aGrid->GetColSize( aCol ) - ( 2 * GRID_CELL_MARGIN ) ); const size_t numLines = GetTextLines( *aGrid, aDC, *attr, rect, aRow, aCol ).size(); - const int textHeight = numLines *aDC.GetCharHeight(); + const int textHeight = numLines * aDC.GetCharHeight(); attr->DecRef(); @@ -778,8 +778,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow() if( new_libid.IsEmpty() || new_libid == m_grid->GetCellValue( row, COL_CURR_LIBID ) ) continue; - // a new lib id is found and was already validated. - // set this new value + // A new lib id is found and was already validated. LIB_ID id; id.Parse( new_libid, LIB_ID::ID_SCH, true ); @@ -788,6 +787,12 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow() if( cmp.m_Row != row ) continue; + SCH_FIELD* value = cmp.m_Component->GetField( VALUE ); + + // If value is a proxy for the itemName then make sure it gets updated + if( cmp.m_Component->GetLibId().GetLibItemName().wx_str() == value->GetText() ) + value->SetText( id.GetLibItemName().wx_str() ); + cmp.m_Component->SetLibId( id ); change = true; cmp.m_Screen->SetModify();