Skip to content

Commit

Permalink
Move initialization to header ; Remove extra clone ; use hasGeometry …
Browse files Browse the repository at this point in the history
…method
  • Loading branch information
lbartoletti committed Aug 21, 2018
1 parent 81974f9 commit d3f602c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/app/qgsmaptoolreverseline.cpp
Expand Up @@ -31,8 +31,6 @@

QgsMapToolReverseLine::QgsMapToolReverseLine( QgsMapCanvas *canvas )
: QgsMapToolEdit( canvas )
, mPressedFid( 0 )
, mPressedPartNum( 0 )
{
mToolName = tr( "Reverse line geometry" );
}
Expand Down Expand Up @@ -103,7 +101,7 @@ void QgsMapToolReverseLine::canvasReleaseEvent( QgsMapMouseEvent *e )
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( mPressedFid ) ).nextFeature( f );
QgsGeometry geom;

if ( f.geometry().constGet() )
if ( f.hasGeometry() )
{
if ( f.geometry().isMultipart() )
{
Expand All @@ -119,8 +117,8 @@ void QgsMapToolReverseLine::canvasReleaseEvent( QgsMapMouseEvent *e )
else
{

std::unique_ptr<QgsCurve> line( static_cast<QgsCurve *>( f.geometry().constGet()->clone() ) );
geom = QgsGeometry( line->reversed() );
geom = QgsGeometry( static_cast< const QgsCurve * >( f.geometry().constGet() )->reversed() );

}

if ( geom )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolreverseline.h
Expand Up @@ -49,8 +49,8 @@ class APP_EXPORT QgsMapToolReverseLine: public QgsMapToolEdit

//The feature and part where the mouse cursor was pressed
//This is used to check whether we are still in the same part at cursor release
QgsFeatureId mPressedFid;
int mPressedPartNum;
QgsFeatureId mPressedFid = 0;
int mPressedPartNum = 0;
};

#endif // QGSMAPTOOLREVERSELINE_H

0 comments on commit d3f602c

Please sign in to comment.