Skip to content
Permalink
Browse files

Move initialization to header ; Remove extra clone ; use hasGeometry …

…method
  • Loading branch information
lbartoletti committed Aug 21, 2018
1 parent 81974f9 commit d3f602c917731562b00a6989ef0b855e8811fefe
Showing with 5 additions and 7 deletions.
  1. +3 −5 src/app/qgsmaptoolreverseline.cpp
  2. +2 −2 src/app/qgsmaptoolreverseline.h
@@ -31,8 +31,6 @@

QgsMapToolReverseLine::QgsMapToolReverseLine( QgsMapCanvas *canvas )
: QgsMapToolEdit( canvas )
, mPressedFid( 0 )
, mPressedPartNum( 0 )
{
mToolName = tr( "Reverse line geometry" );
}
@@ -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() )
{
@@ -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 )
@@ -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.
You can’t perform that action at this time.