Skip to content


Reject features with empty geometry in QgsMapToolAddFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 26, 2013
1 parent 7e79302 commit 208c920
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -265,6 +265,14 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
QMessageBox::critical( 0, tr( "Error" ), tr( "An error was reported during intersection removal" ) );

if ( !f->geometry()->asWkb() ) //avoid intersection might have removed the whole geometry
QMessageBox::critical( 0, tr( "Error" ), tr( "The feature cannot be added because it contains an emtpy geometry" ) );
delete f;

vlayer->beginEditCommand( tr( "Feature added" ) );
Expand Down

1 comment on commit 208c920

Copy link

@gioman gioman commented on 208c920 Feb 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marco, thanks for the fix. I have just one note to add: it seems that in master is not possible to add a polygon when this is digitized "against" an existing one and the latter has errors in it. So in this cases the users will receive a "The feature cannot be added because it contains an empty geometry" message even when they think is doing the right thing (and it really seems like that). So I guess that in this cases a different error message should be thrown. But more important seems the necessity to add an option that would not allow to commit a geometry if this is not valid, see .

Please sign in to comment.