Eeschema: Check for NULL pointer when using interactive delete tool

CHANGED: If you start the interactive delete tool and the mouse pointer
isn't near anything, Eeschema tries to use a null EDA_ITEM pointer
which throws an exception.  This commit checks if the pointer is null
and exits if it is.
This commit is contained in:
PJM 2020-09-29 19:28:23 -07:00 committed by Ian McInerney
parent e7c31f5dba
commit b0e05ad9bf
1 changed files with 12 additions and 9 deletions

View File

@ -726,18 +726,21 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
}
}
EDA_RECT tightBox = closest->GetBoundingBox();
tightBox.Inflate( -tightBox.GetWidth() / 4, -tightBox.GetHeight() / 4 );
for( int i = collector.GetCount() - 1; i >= 0; --i )
if( closest ) // Don't try and get a tight bbox if nothing is near the mouse pointer
{
EDA_ITEM* item = collector[ i ];
EDA_RECT tightBox = closest->GetBoundingBox();
tightBox.Inflate( -tightBox.GetWidth() / 4, -tightBox.GetHeight() / 4 );
if( item == closest )
continue;
for( int i = collector.GetCount() - 1; i >= 0; --i )
{
EDA_ITEM* item = collector[i];
if( !item->HitTest( tightBox, true ) )
collector.Transfer( item );
if( item == closest )
continue;
if( !item->HitTest( tightBox, true ) )
collector.Transfer( item );
}
}
}