Skip to content
Permalink
Browse files

Fix QgsFeaturePool never uses cached feature, always retrieves featur…

…e from layer
  • Loading branch information
nyalldawson committed Aug 19, 2018
1 parent 4a8d84b commit 26e4ea72b580890f5b946818ddd7eadc456e22d9
Showing with 11 additions and 14 deletions.
  1. +11 −14 src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
@@ -60,25 +60,22 @@ QgsFeaturePool::QgsFeaturePool( QgsVectorLayer *layer, double layerToMapUnits, c
bool QgsFeaturePool::get( QgsFeatureId id, QgsFeature &feature )
{
QMutexLocker lock( &mLayerMutex );
QgsFeature *pfeature = mFeatureCache.object( id );
if ( pfeature )
QgsFeature *cachedFeature = mFeatureCache.object( id );
if ( cachedFeature )
{
//feature was cached
feature = *pfeature;
feature = *cachedFeature;
}

// Feature not in cache, retrieve from layer
pfeature = new QgsFeature();
// TODO: avoid always querying all attributes (attribute values are needed when merging by attribute)
if ( !mLayer->getFeatures( QgsFeatureRequest( id ) ).nextFeature( *pfeature ) )
else
{
delete pfeature;
return false;
// Feature not in cache, retrieve from layer
// TODO: avoid always querying all attributes (attribute values are needed when merging by attribute)
if ( !mLayer->getFeatures( QgsFeatureRequest( id ) ).nextFeature( feature ) )
{
return false;
}
mFeatureCache.insert( id, new QgsFeature( feature ) );
}
//make a copy of pfeature into feature parameter
feature = QgsFeature( *pfeature );
//ownership of pfeature is transferred to cache
mFeatureCache.insert( id, pfeature );
return true;
}

0 comments on commit 26e4ea7

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