Skip to content

Commit

Permalink
Fix crash when deleting last node in a geometry (fix #13674)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 29, 2015
1 parent 93facfd commit ba1de8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,15 @@ void QgsMapToolNodeTool::keyPressEvent( QKeyEvent* e )
return;

mSelectedFeature->deleteSelectedVertexes();
safeSelectVertex( firstSelectedIndex );

if ( mSelectedFeature->geometry()->isEmpty() )
{
emit messageEmitted( tr( "Geometry has been cleared. Use the add part tool to set geometry for this feature." ) );
}
else
{
safeSelectVertex( firstSelectedIndex );
}
mCanvas->refresh();

// Override default shortcut management in MapCanvas
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsvectorlayereditutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ bool QgsVectorLayerEditUtils::deleteVertex( QgsFeatureId atFeatureId, int atVert
if ( !geometry.deleteVertex( atVertex ) )
return false;

if ( geometry.geometry() && geometry.geometry()->nCoordinates() == 0 )
{
//last vertex deleted, set geometry to null
geometry.setGeometry( 0 );
}


L->editBuffer()->changeGeometry( atFeatureId, &geometry );
return true;
}
Expand Down

0 comments on commit ba1de8b

Please sign in to comment.