Navigation Menu

Skip to content


Never assume anything
Browse files Browse the repository at this point in the history
because when you do, reality will teach you better
  • Loading branch information
m-kuhn committed Mar 2, 2019
1 parent dcc92de commit 82ca2dd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
Expand Up @@ -38,7 +38,15 @@ QgsFeaturePool::QgsFeaturePool( QgsVectorLayer *layer )

bool QgsFeaturePool::getFeature( QgsFeatureId id, QgsFeature &feature, QgsFeedback *feedback )
QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Read );
// Why is there a write lock acquired here? Weird, we only want to read a feature from the cache, right?
// A method like `QCache::object(const Key &key) const` certainly would not modify its internals.
// Mmmh. What if reality was different?
// If one reads the docs very, very carefully one will find the term "reentrant" in the
// small print of the QCache docs. This is the hint that reality is different.

QgsReadWriteLocker locker( mCacheLock, QgsReadWriteLocker::Write );
QgsFeature *cachedFeature = mFeatureCache.object( id );
if ( cachedFeature )
Expand Down

0 comments on commit 82ca2dd

Please sign in to comment.