Don't crash when deleting last vertex

Fix #12867

Also preserves NULL rectangles in QgsRectangle::normalize()
This commit is contained in:
Matthias Kuhn 2015-06-04 11:30:59 +02:00
parent 385529ef7b
commit 033baf1b0c
2 changed files with 12 additions and 5 deletions

View File

@ -709,8 +709,8 @@ void QgsPointLocator::destroyIndex()
mIsEmptyLayer = false; mIsEmptyLayer = false;
foreach ( QgsGeometry* g, mGeoms ) qDeleteAll( mGeoms );
delete g;
mGeoms.clear(); mGeoms.clear();
} }
@ -743,10 +743,14 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
} }
} }
SpatialIndex::Region r( rect2region( f.constGeometry()->boundingBox() ) ); QgsRectangle bbox = f.constGeometry()->boundingBox();
if ( !bbox.isNull() )
{
SpatialIndex::Region r( rect2region( bbox ) );
mRTree->insertData( 0, 0, r, f.id() ); mRTree->insertData( 0, 0, r, f.id() );
mGeoms[fid] = new QgsGeometry( *f.constGeometry() ); mGeoms[fid] = new QgsGeometry( *f.constGeometry() );
} }
}
} }
void QgsPointLocator::onFeatureDeleted( QgsFeatureId fid ) void QgsPointLocator::onFeatureDeleted( QgsFeatureId fid )

View File

@ -77,6 +77,9 @@ void QgsRectangle::set( double xmin_, double ymin_, double xmax_, double ymax_ )
void QgsRectangle::normalize() void QgsRectangle::normalize()
{ {
if ( isNull() )
return;
if ( xmin > xmax ) if ( xmin > xmax )
{ {
std::swap( xmin, xmax ); std::swap( xmin, xmax );