mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
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. (cherry picked from commit 2ef18ad4ca61c62592f64c495815f127c7b3ac60)
This commit is contained in:
parent
639f59839e
commit
ac8bd587dc
@ -328,7 +328,13 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||||||
SYMBOL_LIB_TABLE* libs = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() );
|
SYMBOL_LIB_TABLE* libs = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() );
|
||||||
SYMBOL_LIB* cache = PROJECT_SCH::SchLibs( &m_frame->Prj() )->GetCacheLibrary();
|
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 )
|
for( SCH_SHEET_PATH& sheet : sheets )
|
||||||
{
|
{
|
||||||
@ -341,15 +347,12 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||||||
LIB_SYMBOL* libSymbol = SchGetLibSymbol( s->GetLibId(), libs, cache );
|
LIB_SYMBOL* libSymbol = SchGetLibSymbol( s->GetLibId(), libs, cache );
|
||||||
|
|
||||||
if( libSymbol )
|
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;
|
std::vector<PICKED_SYMBOL> alreadyPlaced;
|
||||||
|
|
||||||
for( LIB_SYMBOL* libSymbol : part_list )
|
for( LIB_SYMBOL* libSymbol : part_list )
|
||||||
{
|
{
|
||||||
PICKED_SYMBOL pickedSymbol;
|
PICKED_SYMBOL pickedSymbol;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user