From c6d007507635f031d132791fe4ca7040352f99f0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 6 Jan 2018 12:36:08 +0000 Subject: [PATCH] Keep value, footprint and datasheet in sync in multi-unit parts Fixes: lp:1731743 * https://bugs.launchpad.net/kicad/+bug/1731743 --- .../dialog_edit_component_in_schematic.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index e8d1d9d64c..73d63f8c02 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -509,6 +510,32 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event // reference. m_cmp->SetRef( &GetParent()->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() ); + // The value, footprint and datasheet fields should be kept in sync in multi-unit + // parts. + if( m_cmp->GetUnitCount() > 1 ) + { + const LIB_ID thisLibId = m_cmp->GetLibId(); + const wxString thisRef = m_cmp->GetRef( &( GetParent()->GetCurrentSheet() ) ); + int thisUnit = m_cmp->GetUnit(); + + SCH_REFERENCE_LIST components; + GetParent()->GetCurrentSheet().GetComponents( components ); + for( int i = 0; i < components.GetCount(); i++ ) + { + SCH_REFERENCE component = components[i]; + if( component.GetLibPart()->GetLibId() == thisLibId + && component.GetRef() == thisRef + && component.GetUnit() != thisUnit ) + { + SCH_COMPONENT* otherUnit = component.GetComp(); + GetParent()->SaveCopyInUndoList( otherUnit, UR_CHANGED, true /* append */); + otherUnit->GetField( VALUE )->SetText( m_FieldsBuf[VALUE].GetText() ); + otherUnit->GetField( FOOTPRINT )->SetText( m_FieldsBuf[FOOTPRINT].GetText() ); + otherUnit->GetField( DATASHEET )->SetText( m_FieldsBuf[DATASHEET].GetText() ); + } + } + } + GetParent()->OnModify(); GetParent()->GetScreen()->TestDanglingEnds();