Use IsType() for selection testing

Straight Type() comparison breaks for the TYPE_LOCATE values
This commit is contained in:
Seth Hillbrand 2022-11-18 06:29:51 -08:00
parent d63eac9778
commit 7b1702b5fb
1 changed files with 3 additions and 14 deletions

View File

@ -135,7 +135,7 @@ bool SELECTION::HasType( KICAD_T aType ) const
{ {
for( const EDA_ITEM* item : m_items ) for( const EDA_ITEM* item : m_items )
{ {
if( item->Type() == aType ) if( item->IsType( { aType } ) )
return true; return true;
} }
@ -149,7 +149,7 @@ size_t SELECTION::CountType( KICAD_T aType ) const
for( const EDA_ITEM* item : m_items ) for( const EDA_ITEM* item : m_items )
{ {
if( item->Type() == aType ) if( item->IsType( { aType } ) )
count++; count++;
} }
@ -183,18 +183,7 @@ bool SELECTION::OnlyContains( std::vector<KICAD_T> aList ) const
return ( std::all_of( m_items.begin(), m_items.end(), return ( std::all_of( m_items.begin(), m_items.end(),
[&]( const EDA_ITEM* r ) [&]( const EDA_ITEM* r )
{ {
bool ok = false; return r->IsType( aList );
for( const KICAD_T& type : aList )
{
if( r->Type() == type )
{
ok = true;
break;
}
}
return ok;
} ) ); } ) );
} }