Skip to content

Commit eee7577

Browse files
committedSep 6, 2017
Use unique_ptr
1 parent 37b6052 commit eee7577

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed
 

‎src/app/qgsmaptoolcircle3points.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ void QgsMapToolCircle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
6868
{
6969
case 1:
7070
{
71-
QgsLineString *line = new QgsLineString();
71+
std::unique_ptr<QgsLineString> line( new QgsLineString() );
7272
line->addVertex( mPoints.at( 0 ) );
7373
line->addVertex( mapPoint );
74-
mTempRubberBand->setGeometry( line );
74+
mTempRubberBand->setGeometry( line.release() );
7575
}
7676
break;
7777
case 2:

‎src/app/qgsmaptoolellipsecenter2points.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgsmapcanvas.h"
2020
#include "qgspoint.h"
2121
#include <QMouseEvent>
22+
#include <memory>
2223

2324
QgsMapToolEllipseCenter2Points::QgsMapToolEllipseCenter2Points( QgsMapToolCapture *parentTool,
2425
QgsMapCanvas *canvas, CaptureMode mode )
@@ -69,10 +70,10 @@ void QgsMapToolEllipseCenter2Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
6970
{
7071
case 1:
7172
{
72-
QgsLineString *line = new QgsLineString();
73+
std::unique_ptr<QgsLineString> line( new QgsLineString() );
7374
line->addVertex( mPoints.at( 0 ) );
7475
line->addVertex( mapPoint );
75-
mTempRubberBand->setGeometry( line );
76+
mTempRubberBand->setGeometry( line.release() );
7677
}
7778
break;
7879
case 2:

‎src/app/qgsmaptoolellipsefoci.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgsmapcanvas.h"
2020
#include "qgspoint.h"
2121
#include <QMouseEvent>
22+
#include <memory>
2223

2324
QgsMapToolEllipseFoci::QgsMapToolEllipseFoci( QgsMapToolCapture *parentTool,
2425
QgsMapCanvas *canvas, CaptureMode mode )
@@ -67,10 +68,10 @@ void QgsMapToolEllipseFoci::cadCanvasMoveEvent( QgsMapMouseEvent *e )
6768
{
6869
case 1:
6970
{
70-
QgsLineString *line = new QgsLineString();
71+
std::unique_ptr<QgsLineString> line( new QgsLineString() );
7172
line->addVertex( mPoints.at( 0 ) );
7273
line->addVertex( mapPoint );
73-
mTempRubberBand->setGeometry( line );
74+
mTempRubberBand->setGeometry( line.release() );
7475
}
7576
break;
7677
case 2:

‎src/app/qgsmaptoolrectangle3points.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ void QgsMapToolRectangle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
7070
{
7171
case 1:
7272
{
73-
QgsLineString *line = new QgsLineString();
73+
std::unique_ptr<QgsLineString> line( new QgsLineString() );
7474
line->addVertex( mPoints.at( 0 ) );
7575
line->addVertex( mapPoint );
76-
mTempRubberBand->setGeometry( line );
76+
mTempRubberBand->setGeometry( line.release() );
7777
setAzimuth( mPoints.at( 0 ).azimuth( mapPoint ) );
7878
setDistance1( mPoints.at( 0 ).distance( mapPoint ) );
7979
}

0 commit comments

Comments
 (0)
Please sign in to comment.