Skip to content
Permalink
Browse files
Reject features with empty geometry in QgsMapToolAddFeature
  • Loading branch information
mhugent committed Feb 26, 2013
1 parent 7e79302 commit 208c9206ad972b96aef0fdfdebd8012ffa120fe7
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/app/qgsmaptooladdfeature.cpp
@@ -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;
stopCapturing();
return;
}
}

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

1 comment on commit 208c920

@gioman

This comment has been minimized.

Copy link
Contributor

@gioman gioman commented on 208c920 Feb 26, 2013

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 http://hub.qgis.org/issues/7235 .

Please sign in to comment.