Skip to content

Commit

Permalink
Fix crash when using rotation tool with selected feature(s) (fixes #3…
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 8, 2019
1 parent 5c2a3e9 commit 0cafd82
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -233,6 +233,12 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius,
layerCoords.x() + searchRadius, layerCoords.y() + searchRadius );

if ( !mAnchorPoint )
{
mAnchorPoint = qgis::make_unique<QgsVertexMarker>( mCanvas );
mAnchorPoint->setIconType( QgsVertexMarker::ICON_CROSS );
}

if ( vlayer->selectedFeatureCount() == 0 )
{
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setNoAttributes() );
Expand Down Expand Up @@ -269,12 +275,6 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )

QgsRectangle bound = cf.geometry().boundingBox();
mStartPointMapCoords = toMapCoordinates( vlayer, bound.center() );

if ( !mAnchorPoint )
{
mAnchorPoint = qgis::make_unique<QgsVertexMarker>( mCanvas );
}
mAnchorPoint->setIconType( QgsVertexMarker::ICON_CROSS );
mAnchorPoint->setCenter( mStartPointMapCoords );

mStPoint = toCanvasCoordinates( mStartPointMapCoords );
Expand Down Expand Up @@ -326,7 +326,11 @@ void QgsMapToolRotateFeature::cancel()
{
deleteRotationWidget();
deleteRubberband();
mAnchorPoint.reset();
QgsVectorLayer *vlayer = currentVectorLayer();
if ( vlayer->selectedFeatureCount() == 0 )
{
mAnchorPoint.reset();
}
mRotationActive = false;
}

Expand Down Expand Up @@ -465,8 +469,8 @@ void QgsMapToolRotateFeature::deactivate()
{
deleteRotationWidget();
mRotationActive = false;
mAnchorPoint.reset();
mRotationOffset = 0;
mAnchorPoint.reset();
deleteRubberband();
QgsMapTool::deactivate();
}
Expand Down

0 comments on commit 0cafd82

Please sign in to comment.