Implement a forced ordering for LIB_ITEMs until we have UUIDs.
(Once we read/write the UUIDs, we should just compare the type and then the UUID like we do for SCH_ITEMs.)
This commit is contained in:
parent
522359ccbf
commit
4acff58c7a
|
@ -82,12 +82,18 @@ int LIB_ITEM::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareF
|
|||
|
||||
bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
return false;
|
||||
|
||||
return compare( aOther ) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
return Type() < aOther.Type();
|
||||
|
||||
return ( compare( aOther ) < 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -764,10 +764,14 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet )
|
|||
}
|
||||
|
||||
// Enforce item ordering
|
||||
auto cmp = []( const SCH_ITEM* a, const SCH_ITEM* b )
|
||||
{
|
||||
return *a < *b;
|
||||
};
|
||||
auto cmp =
|
||||
[]( const SCH_ITEM* a, const SCH_ITEM* b )
|
||||
{
|
||||
if( a->Type() != b->Type() )
|
||||
return a->Type() < b->Type();
|
||||
|
||||
return a->m_Uuid < b->m_Uuid;
|
||||
};
|
||||
|
||||
std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
|
||||
|
||||
|
@ -1822,7 +1826,19 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& a
|
|||
aFormatter.Print( aNestLevel + 1, "(symbol %s_%d_%d\"\n",
|
||||
name.c_str(), unit.m_unit, unit.m_convert );
|
||||
|
||||
// Enforce item ordering
|
||||
auto cmp =
|
||||
[]( const LIB_ITEM* a, const LIB_ITEM* b )
|
||||
{
|
||||
return *a < *b;
|
||||
};
|
||||
|
||||
std::multiset<LIB_ITEM*, decltype( cmp )> save_map( cmp );
|
||||
|
||||
for( LIB_ITEM* item : unit.m_items )
|
||||
save_map.insert( item );
|
||||
|
||||
for( LIB_ITEM* item : save_map )
|
||||
saveSymbolDrawItem( item, aFormatter, aNestLevel + 2 );
|
||||
|
||||
aFormatter.Print( aNestLevel + 1, ")\n" );
|
||||
|
|
Loading…
Reference in New Issue