Skip to content
Permalink
Browse files

Don't crash when deleting last vertex

Fix #12867

Backported to 2.8.3

Also preserves NULL rectangles in QgsRectangle::normalize()
  • Loading branch information
m-kuhn committed Jun 4, 2015
1 parent cbeacb7 commit 06af43da38c42cb17bb7c8c705418757b4abdc86
Showing with 30 additions and 14 deletions.
  1. +27 −14 src/core/qgspointlocator.cpp
  2. +3 −0 src/core/qgsrectangle.cpp
@@ -632,11 +632,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
QgsRectangle rect = *mExtent;
if ( mTransform )
{
try {
try
{
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
} catch (const QgsException& e) {
}
catch ( const QgsException& e )
{
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform bounding box to map, skipping the snap filter (%1)").arg(e.what()) );
QgsDebugMsg( QString( "could not transform bounding box to map, skipping the snap filter (%1)" ).arg( e.what() ) );
}
}
request.setFilterRect( rect );
@@ -650,11 +653,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )

if ( mTransform )
{
try {
try
{
f.geometry()->transform( *mTransform );
} catch (const QgsException& e) {
}
catch ( const QgsException& e )
{
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
QgsDebugMsg( QString( "could not transform geometry to map, skipping the snap for it (%1)" ).arg( e.what() ) );
continue;
}
}
@@ -700,8 +706,8 @@ void QgsPointLocator::destroyIndex()

mIsEmptyLayer = false;

foreach ( QgsGeometry* g, mGeoms )
delete g;
qDeleteAll( mGeoms );

mGeoms.clear();
}

@@ -722,18 +728,25 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )

if ( mTransform )
{
try {
try
{
f.geometry()->transform( *mTransform );
} catch (const QgsException& e) {
}
catch ( const QgsException& e )
{
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
QgsDebugMsg( QString( "could not transform geometry to map, skipping the snap for it (%1)" ).arg( e.what() ) );
return;
}
}

SpatialIndex::Region r( rect2region( f.geometry()->boundingBox() ) );
mRTree->insertData( 0, 0, r, f.id() );
mGeoms[fid] = new QgsGeometry( *f.geometry() );
QgsRectangle bbox = f.geometry()->boundingBox();
if ( !bbox.isNull() )
{
SpatialIndex::Region r( rect2region( bbox ) );
mRTree->insertData( 0, 0, r, f.id() );
mGeoms[fid] = new QgsGeometry( *f.geometry() );
}
}
}

@@ -77,6 +77,9 @@ void QgsRectangle::set( double xmin_, double ymin_, double xmax_, double ymax_ )

void QgsRectangle::normalize()
{
if ( isNull() )
return;

if ( xmin > xmax )
{
std::swap( xmin, xmax );

0 comments on commit 06af43d

Please sign in to comment.
You can’t perform that action at this time.