Skip to content

Commit

Permalink
unique ptr improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 20, 2018
1 parent 884ccc8 commit 96d1ea5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/app/qgsmaptoolselectradius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,14 @@ void QgsDistanceWidget::distanceSpinBoxValueChanged( double distance )

QgsMapToolSelectRadius::QgsMapToolSelectRadius( QgsMapCanvas *canvas )
: QgsMapTool( canvas )
, mSnapIndicator( new QgsSnapIndicator( canvas ) )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator >( canvas ) )
{
mCursor = Qt::ArrowCursor;
}

QgsMapToolSelectRadius::~QgsMapToolSelectRadius()
{
deleteRotationWidget();
deleteRubberband();
}

void QgsMapToolSelectRadius::canvasMoveEvent( QgsMapMouseEvent *e )
Expand All @@ -125,7 +124,7 @@ void QgsMapToolSelectRadius::canvasMoveEvent( QgsMapMouseEvent *e )

if ( !mRubberBand )
{
mRubberBand = new QgsRubberBand( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setStrokeColor( mStrokeColor );
}
Expand Down Expand Up @@ -157,7 +156,7 @@ void QgsMapToolSelectRadius::canvasReleaseEvent( QgsMapMouseEvent *e )
{
if ( !mRubberBand )
{
mRubberBand = new QgsRubberBand( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setStrokeColor( mStrokeColor );
}
Expand Down Expand Up @@ -242,11 +241,9 @@ void QgsMapToolSelectRadius::cancel()

void QgsMapToolSelectRadius::deleteRubberband()
{
delete mRubberBand;
mRubberBand = nullptr;
mRubberBand.reset();
}


void QgsMapToolSelectRadius::createRotationWidget()
{
if ( !mCanvas )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolselectradius.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class APP_EXPORT QgsMapToolSelectRadius : public QgsMapTool
void createRotationWidget();

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

//! Center point for the radius
Expand Down

0 comments on commit 96d1ea5

Please sign in to comment.