Fixed a segfault with simplify tool (#2450)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13176 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2010-03-28 08:34:54 +00:00
parent 26f4b4513e
commit a066fe33eb

View File

@ -259,7 +259,7 @@ void QgsMapToolSimplify::canvasPressEvent( QMouseEvent * e )
vlayer->select( QgsAttributeList(), selectRect, true ); vlayer->select( QgsAttributeList(), selectRect, true );
QgsGeometry* geometry = QgsGeometry::fromPoint( layerCoords ); QgsGeometry* geometry = QgsGeometry::fromPoint( layerCoords );
double minDistance = 10000000; double minDistance = DBL_MAX;
double currentDistance; double currentDistance;
QgsFeature f; QgsFeature f;
@ -274,16 +274,18 @@ void QgsMapToolSimplify::canvasPressEvent( QMouseEvent * e )
mSelectedFeature = f; mSelectedFeature = f;
} }
} }
if ( mSelectedFeature.geometry()->isMultipart() )
{
QMessageBox::critical( 0, tr( "Unsupported operation" ), tr( "Multipart features are not supported for simplification." ) );
return;
}
// delete previous rubberband (if any) // delete previous rubberband (if any)
removeRubberBand(); removeRubberBand();
if ( mSelectedFeature.isValid() ) if ( mSelectedFeature.isValid() )
{ {
if ( mSelectedFeature.geometry()->isMultipart() )
{
QMessageBox::critical( 0, tr( "Unsupported operation" ), tr( "Multipart features are not supported for simplification." ) );
return;
}
mRubberBand = new QgsRubberBand( mCanvas ); mRubberBand = new QgsRubberBand( mCanvas );
mRubberBand->setToGeometry( mSelectedFeature.geometry(), false ); mRubberBand->setToGeometry( mSelectedFeature.geometry(), false );
mRubberBand->setColor( Qt::red ); mRubberBand->setColor( Qt::red );