From 840a8b1d36a8f1c90da507069fc573210974b862 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 10 Jul 2018 17:51:14 +0200 Subject: [PATCH] Eeschema, renumbering components: Fix multiparts IC supply renumber problem. With "reset but keep order of multi-units parts" option on, these units were incorrectly grouped. Fixes: lp:1780876 https://bugs.launchpad.net/kicad/+bug/1780876 --- eeschema/component_references_lister.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index d8a93f31e9..a987b2943e 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -273,11 +273,15 @@ int SCH_REFERENCE_LIST::CreateFirstFreeRefId( std::vector& aIdList, int aFi // A helper function to build a full reference string of a SCH_REFERENCE item -wxString buildFullReference( const SCH_REFERENCE& aItem ) +wxString buildFullReference( const SCH_REFERENCE& aItem, int aUnitNumber = -1 ) { wxString fullref; fullref = aItem.GetRef() + aItem.GetRefNumber(); - fullref << ".." << aItem.GetUnit(); + + if( aUnitNumber < 0 ) + fullref << ".." << aItem.GetUnit(); + else + fullref << ".." << aUnitNumber; return fullref; } @@ -344,6 +348,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : aLockedUnitMap ) { unsigned n_refs = pair.second.GetCount(); + for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI ) { SCH_REFERENCE &thisRef = pair.second[thisRefI]; @@ -433,6 +438,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int { // This is the component we're currently annotating. Hold the unit! componentFlatList[ii].m_Unit = thisRef.m_Unit; + // lock this new full reference + inUseRefs.insert( buildFullReference( componentFlatList[ii] ) ); } if( thisRef.CompareValue( componentFlatList[ii] ) != 0 ) @@ -447,7 +454,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int if( ! thisRef.IsSameInstance( componentFlatList[jj] ) ) continue; - wxString ref_candidate = buildFullReference( componentFlatList[ii] ); + wxString ref_candidate = buildFullReference( componentFlatList[ii], thisRef.m_Unit ); // propagate the new reference and unit selection to the "old" component, // if this new full reference is not already used (can happens when initial @@ -465,7 +472,6 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int } } } - else { /* search for others units of this component.