Skip to content

Commit

Permalink
Only use one single lock
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 7, 2018
1 parent e41680a commit ea15e44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
Expand Up @@ -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;
}
Expand All @@ -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();
Expand All @@ -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 );
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/vector/geometry_checker/qgsfeaturepool.h
Expand Up @@ -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;
Expand Down

0 comments on commit ea15e44

Please sign in to comment.