From 2e21489acfa896dfad18ae488cb0d4997581ba63 Mon Sep 17 00:00:00 2001 From: david-beinder Date: Thu, 21 Jan 2021 18:36:59 +0100 Subject: [PATCH] Copy unit numbers to symbol instances when pasting sheets Fixes https://gitlab.com/kicad/code/kicad/issues/5898 (B) --- eeschema/tools/sch_editor_control.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 87850fbfeb..280a256c94 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1300,21 +1300,23 @@ void SCH_EDITOR_CONTROL::updatePastedInstances( const SCH_SHEET_PATH& aPastePath { SCH_COMPONENT* symbol = static_cast( item ); - if( aForceKeepAnnotations ) + KIID_PATH clipItemPath = aClipPath; + clipItemPath.push_back( symbol->m_Uuid ); + + // SCH_REFERENCE_LIST doesn't include the root sheet in the path + clipItemPath.erase( clipItemPath.begin() ); + + int ii = m_supplementaryClipboardInstances.FindRefByPath( clipItemPath.AsString() ); + + if( ii >= 0 ) { - KIID_PATH clipItemPath = aClipPath; - clipItemPath.push_back( symbol->m_Uuid ); + SCH_REFERENCE instance = m_supplementaryClipboardInstances[ ii ]; - // SCH_REFERENCE_LIST doesn't include the root sheet in the path - clipItemPath.erase( clipItemPath.begin() ); + symbol->SetUnitSelection( &aPastePath, instance.GetUnit() ); + symbol->SetUnit( instance.GetUnit() ); - int ii = m_supplementaryClipboardInstances.FindRefByPath( clipItemPath.AsString() ); - - if( ii >= 0 ) + if( aForceKeepAnnotations ) { - SCH_REFERENCE instance = m_supplementaryClipboardInstances[ ii ]; - - symbol->SetUnit( instance.GetUnit() ); symbol->SetRef( &aPastePath, instance.GetRef() ); symbol->SetValue( &aPastePath, instance.GetValue() ); symbol->SetFootprint( &aPastePath, instance.GetFootprint() );