Insert the same unit on all sheet instances when adding a symbol

Fixes https://gitlab.com/kicad/code/kicad/issues/5898 (C)
This commit is contained in:
david-beinder 2021-01-21 21:00:09 +01:00 committed by Seth Hillbrand
parent 2e21489acf
commit 1598e870b6
3 changed files with 13 additions and 1 deletions

View File

@ -576,6 +576,13 @@ void SCH_COMPONENT::SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSel
}
void SCH_COMPONENT::SetUnitSelection( int aUnitSelection )
{
for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
instance.m_Unit = aUnitSelection;
}
const wxString SCH_COMPONENT::GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const
{
KIID_PATH path = sheet->Path();

View File

@ -553,8 +553,13 @@ public:
// Returns the instance-specific unit selection for the given sheet path.
int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
// Set the selected unit of this symbol on one sheet
void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
// Set the selected unit of this symbol for all sheets
void SetUnitSelection( int aUnitSelection );
// Returns the instance-specific value for the given sheet path.
const wxString GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const;
void SetValue( const SCH_SHEET_PATH* sheet, const wxString& aValue );

View File

@ -252,7 +252,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
next_comp = static_cast<SCH_COMPONENT*>( component->Duplicate() );
next_comp->SetFlags( IS_NEW | IS_MOVED );
next_comp->SetUnit( new_unit );
next_comp->SetUnitSelection( &m_frame->GetCurrentSheet(), new_unit );
next_comp->SetUnitSelection( new_unit );
if( m_frame->eeconfig()->m_AutoplaceFields.enable )
component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );