pcbnew: Don't compare across containers

std:: defines cross-container comparison as invalid and is not
guaranteed to work.  This breaks the comparison out into separate
steps, each for the separate containers.
This commit is contained in:
Seth Hillbrand 2020-01-06 20:01:21 -08:00
parent 9dff31c2ac
commit 16026e75cf
1 changed files with 13 additions and 19 deletions

View File

@ -112,28 +112,22 @@ int ALIGN_DISTRIBUTE_TOOL::selectTarget( ALIGNMENT_RECTS& aItems, ALIGNMENT_RECT
// unless we have a locked item, in which case we use that for the target // unless we have a locked item, in which case we use that for the target
int target = !aLocked.size() ? aGetValue( aItems.front() ): aGetValue( aLocked.front() ); int target = !aLocked.size() ? aGetValue( aItems.front() ): aGetValue( aLocked.front() );
// Iterate through both lists to find if we are mouse-over on one of the items.
for( auto sel = aLocked.begin(); sel != aItems.end(); sel++ )
{
// If there are locked items, prefer aligning to them over
// aligning to the cursor as they do not move
if( sel == aLocked.end() )
{
if( aLocked.size() == 0 )
{
sel = aItems.begin();
continue;
}
break;
}
// We take the first target that overlaps our cursor. // We take the first target that overlaps our cursor.
// This is deterministic because we assume sorted arrays // This is deterministic because we assume sorted arrays
if( sel->second.Contains( curPos ) ) for( auto item : aLocked )
{ {
target = aGetValue( *sel ); if( item.second.Contains( curPos ) )
break; return aGetValue( item );
}
// If there are locked items, prefer aligning to them over
// aligning to the cursor as they do not move
if( aLocked.empty() )
{
for( auto item : aItems )
{
if( item.second.Contains( curPos ) )
return aGetValue( item );
} }
} }