From d5ca5554c30b94083e78e0e26c2f0435e66c0726 Mon Sep 17 00:00:00 2001 From: Jaka Kranjc Date: Fri, 17 Feb 2012 19:41:58 +0100 Subject: [PATCH 1/2] fixed crash when trying to add features with invalid geometry QgsMapToolAddFeature::canvasReleaseEvent wasn't checking if geos returned a sane geometry. One simple way of triggering the crash is to click twice on the same point and then complete the op by rightclicking. Of course this is not a real polygon, so things went haywire after that. --- src/app/qgsmaptooladdfeature.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index 55ec0b0d93ed..dcfb080b9f59 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -242,6 +242,11 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) return; //unknown wkbtype } + if ( !g ) + { + stopCapturing(); + return; // invalid geometry; one possibility is from duplicate points + } f->setGeometry( g ); int avoidIntersectionsReturn = f->geometry()->avoidIntersections(); From 974fe9531b0d9e0b913011bd704ff1c41b9324ea Mon Sep 17 00:00:00 2001 From: Jaka Kranjc Date: Fri, 17 Feb 2012 19:44:07 +0100 Subject: [PATCH 2/2] removed extraneus pointer redeclaration --- src/app/qgsmaptooladdfeature.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index dcfb080b9f59..193c61605160 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -226,7 +226,6 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) } else // polygon { - QgsGeometry *g; if ( layerWKBType == QGis::WKBPolygon || layerWKBType == QGis::WKBPolygon25D ) { g = QgsGeometry::fromPolygon( QgsPolygon() << points().toVector() );