Sort references before removing duplicates.
std::unique only works within consecutive blocks, so the list must be sorted first. (We need it sorted in the end anyway, so no big deal.)
This commit is contained in:
parent
d1a679e496
commit
90df7a8b22
|
@ -815,16 +815,7 @@ void SCH_REFERENCE::Split()
|
||||||
wxString SCH_REFERENCE_LIST::Shorthand( std::vector<SCH_REFERENCE> aList )
|
wxString SCH_REFERENCE_LIST::Shorthand( std::vector<SCH_REFERENCE> aList )
|
||||||
{
|
{
|
||||||
wxString retVal;
|
wxString retVal;
|
||||||
|
size_t i = 0;
|
||||||
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;
|
|
||||||
|
|
||||||
while( i < aList.size() )
|
while( i < aList.size() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -271,16 +271,26 @@ public:
|
||||||
if( aCol == REFERENCE || aCol == QUANTITY_COLUMN )
|
if( aCol == REFERENCE || aCol == QUANTITY_COLUMN )
|
||||||
{
|
{
|
||||||
// Remove duplicates (other units of multi-unit parts)
|
// Remove duplicates (other units of multi-unit parts)
|
||||||
auto logicalEnd = std::unique( references.begin(), references.end(),
|
std::sort( references.begin(), references.end(),
|
||||||
[]( const SCH_REFERENCE& l, const SCH_REFERENCE& r )
|
[]( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool
|
||||||
{
|
{
|
||||||
// If unannotated then we can't tell what units belong together
|
wxString l_ref( l.GetRef() << l.GetRefNumber() );
|
||||||
// so we have to leave them all
|
wxString r_ref( r.GetRef() << r.GetRefNumber() );
|
||||||
if( l.GetRefNumber() == wxT( "?" ) )
|
return RefDesStringCompare( l_ref, r_ref ) < 0;
|
||||||
return false;
|
} );
|
||||||
|
|
||||||
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() );
|
references.erase( logicalEnd, references.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue