From b0e05ad9bfb60ef7430f354b4dbc2675f36e5d1b Mon Sep 17 00:00:00 2001 From: PJM Date: Tue, 29 Sep 2020 19:28:23 -0700 Subject: [PATCH] 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. --- eeschema/tools/ee_selection_tool.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 07e0373981..7f09bf43b0 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -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 ); + } } }