Skip to content
Permalink
Browse files

Only use one single lock

  • Loading branch information
m-kuhn committed Sep 7, 2018
1 parent e41680a commit ea15e44bd59b07b9fa9fa8580343360437f83ffd
@@ -70,7 +70,7 @@ QgsFeatureIds QgsFeaturePool::getFeatureIds() const

QgsFeatureIds QgsFeaturePool::getIntersects( const QgsRectangle &rect ) const
{
QgsReadWriteLocker locker( mIndexLock, QgsReadWriteLocker::Read );
QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Read );
QgsFeatureIds ids = QgsFeatureIds::fromList( mIndex.intersects( rect ) );
return ids;
}
@@ -84,14 +84,14 @@ QgsVectorLayer *QgsFeaturePool::layer() const

void QgsFeaturePool::insertFeature( const QgsFeature &feature )
{
QgsReadWriteLocker locker( mIndexLock, QgsReadWriteLocker::Write );
QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Write );
mFeatureCache.insert( feature.id(), new QgsFeature( feature ) );
mIndex.insertFeature( feature );
}

void QgsFeaturePool::refreshCache( const QgsFeature &feature )
{
QgsReadWriteLocker locker( mIndexLock, QgsReadWriteLocker::Write );
QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Write );
mFeatureCache.remove( feature.id() );
mIndex.deleteFeature( feature );
locker.unlock();
@@ -103,7 +103,7 @@ void QgsFeaturePool::refreshCache( const QgsFeature &feature )
void QgsFeaturePool::removeFeature( const QgsFeatureId featureId )
{
QgsFeature origFeature;
QgsReadWriteLocker locker( mIndexLock, QgsReadWriteLocker::Unlocked );
QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Unlocked );
if ( get( featureId, origFeature ) )
{
locker.changeMode( QgsReadWriteLocker::Write );
@@ -132,9 +132,8 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink
static const int CACHE_SIZE = 1000;
QCache<QgsFeatureId, QgsFeature> mFeatureCache;
QPointer<QgsVectorLayer> mLayer;
QReadWriteLock mCacheLock;
mutable QReadWriteLock mCacheLock;
QgsFeatureIds mFeatureIds;
mutable QReadWriteLock mIndexLock;
QgsSpatialIndex mIndex;
double mLayerToMapUnits = 1.0;
QgsCoordinateTransform mLayerToMapTransform;

0 comments on commit ea15e44

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