Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix leaks in QgsPointLocator
  • Loading branch information
nyalldawson committed Aug 26, 2015
1 parent a417dcf commit c9a0055
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/qgspointlocator.cpp
Expand Up @@ -670,6 +670,9 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )

SpatialIndex::Region r( rect2region( f.constGeometry()->boundingBox() ) );
dataList << new RTree::Data( 0, 0, r, f.id() );

if ( mGeoms.contains( f.id() ) )
delete mGeoms.take( f.id() );
mGeoms[f.id()] = new QgsGeometry( *f.constGeometry() );
++indexedCount;

Expand Down Expand Up @@ -748,6 +751,9 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
{
SpatialIndex::Region r( rect2region( bbox ) );
mRTree->insertData( 0, 0, r, f.id() );

if ( mGeoms.contains( f.id() ) )
delete mGeoms.take( f.id() );
mGeoms[fid] = new QgsGeometry( *f.constGeometry() );
}
}
Expand All @@ -761,7 +767,7 @@ void QgsPointLocator::onFeatureDeleted( QgsFeatureId fid )
if ( mGeoms.contains( fid ) )
{
mRTree->deleteData( rect2region( mGeoms[fid]->boundingBox() ), fid );
mGeoms.remove( fid );
delete mGeoms.take( fid );
}
}

Expand Down

0 comments on commit c9a0055

Please sign in to comment.