diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 613da3f3bc..c2b58a42d3 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -815,16 +815,7 @@ void SCH_REFERENCE::Split() wxString SCH_REFERENCE_LIST::Shorthand( std::vector aList ) { wxString retVal; - - std::sort( aList.begin(), aList.end(), - []( const SCH_REFERENCE& lhs, const SCH_REFERENCE& rhs ) -> bool - { - wxString lhRef( lhs.GetRef() << lhs.GetRefNumber() ); - wxString rhRef( rhs.GetRef() << rhs.GetRefNumber() ); - return RefDesStringCompare( lhRef, rhRef ) < 0; - } ); - - size_t i = 0; + size_t i = 0; while( i < aList.size() ) { diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index f893fc1b7c..a306de71b2 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -271,16 +271,26 @@ public: if( aCol == REFERENCE || aCol == QUANTITY_COLUMN ) { // Remove duplicates (other units of multi-unit parts) - auto logicalEnd = std::unique( references.begin(), references.end(), - []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) - { - // If unannotated then we can't tell what units belong together - // so we have to leave them all - if( l.GetRefNumber() == wxT( "?" ) ) - return false; + std::sort( references.begin(), references.end(), + []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool + { + wxString l_ref( l.GetRef() << l.GetRefNumber() ); + wxString r_ref( r.GetRef() << r.GetRefNumber() ); + return RefDesStringCompare( l_ref, r_ref ) < 0; + } ); - return( l.GetRef() == r.GetRef() && l.GetRefNumber() == r.GetRefNumber() ); - } ); + auto logicalEnd = std::unique( references.begin(), references.end(), + []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool + { + // If unannotated then we can't tell what units belong together + // so we have to leave them all + if( l.GetRefNumber() == wxT( "?" ) ) + return false; + + wxString l_ref( l.GetRef() << l.GetRefNumber() ); + wxString r_ref( r.GetRef() << r.GetRefNumber() ); + return l_ref == r_ref; + } ); references.erase( logicalEnd, references.end() ); }