diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 991345310d..1556681569 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -729,8 +729,8 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() } } - // The value, footprint and datasheet fields, alternate pin assignements, and include/exclude - // flags should be kept in sync in multi-unit parts. + // Keep fields other than the reference, include/exclude flags, and alternate pin assignements + // in sync in multi-unit parts. if( m_symbol->GetUnitCount() > 1 && m_symbol->IsAnnotated( &GetParent()->GetCurrentSheet() ) ) { wxString ref = m_symbol->GetRef( &GetParent()->GetCurrentSheet() ); @@ -751,7 +751,30 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() appendUndo ); otherUnit->SetValue( m_fields->at( VALUE_FIELD ).GetText() ); otherUnit->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() ); - otherUnit->GetField( DATASHEET_FIELD )->SetText( m_fields->at( DATASHEET_FIELD ).GetText() ); + + for( size_t ii = DATASHEET_FIELD; ii < m_fields->size(); ++ii ) + { + SCH_FIELD* otherField = otherUnit->FindField( m_fields->at( ii ).GetName() ); + + if( otherField ) + { + otherField->SetText( m_fields->at( ii ).GetText() ); + } + else + { + SCH_FIELD* newField = otherUnit->AddField( m_fields->at( ii ) ); + const_cast( newField->m_Uuid ) = KIID(); + } + } + + for( size_t ii = otherUnit->GetFields().size() - 1; ii > DATASHEET_FIELD; ii-- ) + { + SCH_FIELD& otherField = otherUnit->GetFields().at( ii ); + + if( !m_symbol->FindField( otherField.GetName() ) ) + otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii ); + } + otherUnit->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() ); otherUnit->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() ); diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 73599aafae..248d2b5ed7 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -695,13 +695,13 @@ private: */ wxString m_schLibSymbolName; - TRANSFORM m_transform; ///< The rotation/mirror transformation matrix. - SCH_FIELDS m_fields; ///< Variable length list of fields. + TRANSFORM m_transform; ///< The rotation/mirror transformation. + std::vector m_fields; ///< Variable length list of fields. - std::unique_ptr< LIB_SYMBOL > m_part; // a flattened copy of the LIB_SYMBOL from - // the PROJECT's libraries. - std::vector> m_pins; // a SCH_PIN for every LIB_PIN (all units) - std::unordered_map m_pinMap; // library pin pointer to SCH_PIN's index + std::unique_ptr< LIB_SYMBOL > m_part; ///< a flattened copy of the LIB_SYMBOL + ///< from the PROJECT's libraries. + std::vector> m_pins; ///< a SCH_PIN for every LIB_PIN (all units) + std::unordered_map m_pinMap; ///< library pin pointer : SCH_PIN's index bool m_isInNetlist; ///< True if the symbol should appear in the netlist bool m_inBom; ///< True to include in bill of materials export.