Remove all instances from a collector when requested

Perhaps COLLECTOR should use a set, but going for the
less invasive change for now.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5934
This commit is contained in:
Jon Evans 2020-10-12 20:06:43 -04:00
parent 7b5d628e4b
commit 74e86a289d
1 changed files with 6 additions and 8 deletions

View File

@ -143,14 +143,12 @@ public:
*/
void Remove( const EDA_ITEM* aItem )
{
for( size_t i = 0; i < m_list.size(); i++ )
{
if( m_list[i] == aItem )
{
m_list.erase( m_list.begin() + i);
return;
}
}
m_list.erase( std::remove_if( m_list.begin(), m_list.end(),
[&aItem]( const EDA_ITEM* aCandidate )
{
return aCandidate == aItem;
} ),
m_list.end() );
}
/**