Fix deduplication of already-placed symbols
The comparison function was failing to properly de-duplicate by LIB_ID, especially for parts from database libraries, causing the list to grow with the size of the design.
This commit is contained in:
parent
1a76fce255
commit
2ef18ad4ca
|
@ -159,6 +159,7 @@ public:
|
|||
virtual void SetName( const wxString& aName );
|
||||
wxString GetName() const override { return m_name; }
|
||||
|
||||
const LIB_ID& LibId() const { return m_libId; }
|
||||
LIB_ID& LibId() { return m_libId; }
|
||||
LIB_ID GetLibId() const override { return m_libId; }
|
||||
void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
|
||||
|
|
|
@ -308,7 +308,13 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
SYMBOL_LIB_TABLE* libs = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() );
|
||||
SYMBOL_LIB* cache = PROJECT_SCH::SchLibs( &m_frame->Prj() )->GetCacheLibrary();
|
||||
|
||||
std::vector<LIB_SYMBOL*> part_list;
|
||||
auto compareByLibID =
|
||||
[]( const LIB_SYMBOL* aFirst, const LIB_SYMBOL* aSecond ) -> bool
|
||||
{
|
||||
return aFirst->LibId().Format() < aSecond->LibId().Format();
|
||||
};
|
||||
|
||||
std::set<LIB_SYMBOL*, decltype( compareByLibID )> part_list( compareByLibID );
|
||||
|
||||
for( SCH_SHEET_PATH& sheet : sheets )
|
||||
{
|
||||
|
@ -321,15 +327,12 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
LIB_SYMBOL* libSymbol = SchGetLibSymbol( s->GetLibId(), libs, cache );
|
||||
|
||||
if( libSymbol )
|
||||
part_list.push_back( libSymbol );
|
||||
part_list.insert( libSymbol );
|
||||
}
|
||||
}
|
||||
|
||||
// Remove redundant parts
|
||||
sort( part_list.begin(), part_list.end() );
|
||||
part_list.erase( unique( part_list.begin(), part_list.end() ), part_list.end() );
|
||||
|
||||
std::vector<PICKED_SYMBOL> alreadyPlaced;
|
||||
|
||||
for( LIB_SYMBOL* libSymbol : part_list )
|
||||
{
|
||||
PICKED_SYMBOL pickedSymbol;
|
||||
|
|
Loading…
Reference in New Issue