Skip to content

Commit 938ee1a

Browse files
author
wonder
committedJul 6, 2009
Fix crash in simplify tool, from Richard Kostecky
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11028 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/app/qgsmaptoolsimplify.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void QgsSimplifyDialog::setRange( int minValue, int maxValue )
5252
// let's have 20 page steps
5353
horizontalSlider->setPageStep(( maxValue - minValue ) / 20 );
5454

55-
horizontalSlider->setMinimum( minValue - 1 );// -1 for count with minimum tolerance end caused by double imprecision
55+
horizontalSlider->setMinimum( (minValue - 1 < 0 ? 0: minValue - 1 ) );// -1 for count with minimum tolerance end caused by double imprecision
5656
horizontalSlider->setMaximum( maxValue );
5757

5858
}
@@ -355,6 +355,7 @@ bool QgsSimplifyFeature::simplifyPolygon( QgsFeature& polygonFeature, double to
355355
{
356356
return FALSE;
357357
}
358+
358359
QVector<QgsPoint> resultPoints = simplifyPoints( polygon->asPolygon()[0], tolerance );
359360
//resultPoints.push_back(resultPoints[0]);
360361
QVector<QgsPolyline> poly;
@@ -366,6 +367,9 @@ bool QgsSimplifyFeature::simplifyPolygon( QgsFeature& polygonFeature, double to
366367

367368
QVector<QgsPoint> QgsSimplifyFeature::simplifyPoints( const QVector<QgsPoint>& pts, double tolerance )
368369
{
370+
//just safety precaution
371+
if (tolerance < 0)
372+
return pts;
369373
// Douglas-Peucker simplification algorithm
370374

371375
int anchor = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.