Skip to content

Commit 033baf1

Browse files
committed
Don't crash when deleting last vertex
Fix #12867 Also preserves NULL rectangles in QgsRectangle::normalize()
1 parent 385529e commit 033baf1

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/core/qgspointlocator.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,8 @@ void QgsPointLocator::destroyIndex()
709709

710710
mIsEmptyLayer = false;
711711

712-
foreach ( QgsGeometry* g, mGeoms )
713-
delete g;
712+
qDeleteAll( mGeoms );
713+
714714
mGeoms.clear();
715715
}
716716

@@ -743,9 +743,13 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
743743
}
744744
}
745745

746-
SpatialIndex::Region r( rect2region( f.constGeometry()->boundingBox() ) );
747-
mRTree->insertData( 0, 0, r, f.id() );
748-
mGeoms[fid] = new QgsGeometry( *f.constGeometry() );
746+
QgsRectangle bbox = f.constGeometry()->boundingBox();
747+
if ( !bbox.isNull() )
748+
{
749+
SpatialIndex::Region r( rect2region( bbox ) );
750+
mRTree->insertData( 0, 0, r, f.id() );
751+
mGeoms[fid] = new QgsGeometry( *f.constGeometry() );
752+
}
749753
}
750754
}
751755

src/core/qgsrectangle.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ void QgsRectangle::set( double xmin_, double ymin_, double xmax_, double ymax_ )
7777

7878
void QgsRectangle::normalize()
7979
{
80+
if ( isNull() )
81+
return;
82+
8083
if ( xmin > xmax )
8184
{
8285
std::swap( xmin, xmax );

0 commit comments

Comments
 (0)