Skip to content
Permalink
Browse files

Fix crash in Select by Radius

If a radius value is entered immediately after clicking with the
tool (before any mouse movement), it would trigger a crash
  • Loading branch information
nyalldawson committed Mar 16, 2018
1 parent dc0da6f commit 9e01a04a49bedb891c07a3d4104b840e1c263052
Showing with 14 additions and 6 deletions.
  1. +12 −6 src/app/qgsmaptoolselectradius.cpp
  2. +2 −0 src/app/qgsmaptoolselectradius.h
@@ -124,9 +124,7 @@ void QgsMapToolSelectRadius::canvasMoveEvent( QgsMapMouseEvent *e )

if ( !mRubberBand )
{
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setStrokeColor( mStrokeColor );
createRubberBand();
}

updateRadiusFromEdge( radiusEdge );
@@ -156,9 +154,7 @@ void QgsMapToolSelectRadius::canvasReleaseEvent( QgsMapMouseEvent *e )
{
if ( !mRubberBand )
{
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setStrokeColor( mStrokeColor );
createRubberBand();
}
QgsPointXY radiusEdge = e->snapPoint();
updateRadiusFromEdge( radiusEdge );
@@ -205,6 +201,9 @@ void QgsMapToolSelectRadius::keyReleaseEvent( QKeyEvent *e )

void QgsMapToolSelectRadius::updateRubberband( const double &radius )
{
if ( !mRubberBand )
createRubberBand();

mRubberBand->reset( QgsWkbTypes::PolygonGeometry );
for ( int i = 0; i <= RADIUS_SEGMENTS; ++i )
{
@@ -262,6 +261,13 @@ void QgsMapToolSelectRadius::createRotationWidget()
connect( mDistanceWidget, &QgsDistanceWidget::distanceEditingCanceled, this, &QgsMapToolSelectRadius::cancel );
}

void QgsMapToolSelectRadius::createRubberBand()
{
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setStrokeColor( mStrokeColor );
}

void QgsMapToolSelectRadius::deleteRotationWidget()
{
if ( mDistanceWidget )
@@ -103,6 +103,8 @@ class APP_EXPORT QgsMapToolSelectRadius : public QgsMapTool
void deleteRotationWidget();
void createRotationWidget();

void createRubberBand();

//! used for storing all of the maps point for the polygon
std::unique_ptr< QgsRubberBand > mRubberBand;
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

0 comments on commit 9e01a04

Please sign in to comment.
You can’t perform that action at this time.