Skip to content

Commit 96d1ea5

Browse files
committedJan 20, 2018
unique ptr improvements
1 parent 884ccc8 commit 96d1ea5

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed
 

‎src/app/qgsmaptoolselectradius.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,14 @@ void QgsDistanceWidget::distanceSpinBoxValueChanged( double distance )
104104

105105
QgsMapToolSelectRadius::QgsMapToolSelectRadius( QgsMapCanvas *canvas )
106106
: QgsMapTool( canvas )
107-
, mSnapIndicator( new QgsSnapIndicator( canvas ) )
107+
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator >( canvas ) )
108108
{
109109
mCursor = Qt::ArrowCursor;
110110
}
111111

112112
QgsMapToolSelectRadius::~QgsMapToolSelectRadius()
113113
{
114114
deleteRotationWidget();
115-
deleteRubberband();
116115
}
117116

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

126125
if ( !mRubberBand )
127126
{
128-
mRubberBand = new QgsRubberBand( mCanvas, QgsWkbTypes::PolygonGeometry );
127+
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
129128
mRubberBand->setFillColor( mFillColor );
130129
mRubberBand->setStrokeColor( mStrokeColor );
131130
}
@@ -157,7 +156,7 @@ void QgsMapToolSelectRadius::canvasReleaseEvent( QgsMapMouseEvent *e )
157156
{
158157
if ( !mRubberBand )
159158
{
160-
mRubberBand = new QgsRubberBand( mCanvas, QgsWkbTypes::PolygonGeometry );
159+
mRubberBand = qgis::make_unique< QgsRubberBand >( mCanvas, QgsWkbTypes::PolygonGeometry );
161160
mRubberBand->setFillColor( mFillColor );
162161
mRubberBand->setStrokeColor( mStrokeColor );
163162
}
@@ -242,11 +241,9 @@ void QgsMapToolSelectRadius::cancel()
242241

243242
void QgsMapToolSelectRadius::deleteRubberband()
244243
{
245-
delete mRubberBand;
246-
mRubberBand = nullptr;
244+
mRubberBand.reset();
247245
}
248246

249-
250247
void QgsMapToolSelectRadius::createRotationWidget()
251248
{
252249
if ( !mCanvas )

‎src/app/qgsmaptoolselectradius.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class APP_EXPORT QgsMapToolSelectRadius : public QgsMapTool
104104
void createRotationWidget();
105105

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

110110
//! Center point for the radius

0 commit comments

Comments
 (0)
Please sign in to comment.