Skip to content

Commit

Permalink
Refresh feature after update
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 6, 2018
1 parent 3557228 commit c55196c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
Expand Up @@ -89,13 +89,15 @@ void QgsFeaturePool::insertFeature( const QgsFeature &feature )
mIndex.insertFeature( feature );
}

void QgsFeaturePool::changeFeature( const QgsFeature &feature )
void QgsFeaturePool::refreshCache( const QgsFeature &feature )
{
QgsReadWriteLocker locker( mIndexLock, QgsReadWriteLocker::Write );
mFeatureCache.remove( feature.id() );
mFeatureCache.insert( feature.id(), new QgsFeature( feature ) );
mIndex.deleteFeature( feature );
mIndex.insertFeature( feature );
locker.unlock();

QgsFeature tempFeature;
get( feature.id(), tempFeature );
}

void QgsFeaturePool::removeFeature( const QgsFeatureId featureId )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/geometry_checker/qgsfeaturepool.h
Expand Up @@ -117,7 +117,7 @@ class ANALYSIS_EXPORT QgsFeaturePool
* Changes a feature in the cache and the spatial index.
* To be used by implementations of ``updateFeature``.
*/
void changeFeature( const QgsFeature &feature );
void refreshCache( const QgsFeature &feature );

/**
* Removes a feature from the cache and the spatial index.
Expand Down
Expand Up @@ -110,7 +110,6 @@ void QgsVectorDataProviderFeaturePool::updateFeature( QgsFeature &feature )
}
changedAttributesMap.insert( feature.id(), attribMap );

removeFeature( origFeature.id() );
runOnMainThread( [this, geometryMap, changedAttributesMap]()
{
QgsVectorLayer *lyr = layer();
Expand All @@ -121,7 +120,7 @@ void QgsVectorDataProviderFeaturePool::updateFeature( QgsFeature &feature )
}
} );

insertFeature( feature );
refreshCache( feature );
}

void QgsVectorDataProviderFeaturePool::deleteFeature( QgsFeatureId fid )
Expand Down

0 comments on commit c55196c

Please sign in to comment.