Skip to content
Permalink
Browse files

Merge pull request #8724 from mhugo/fix_vertex_tool_cache

Fix vertextool's geometry cache invalidation
  • Loading branch information
mhugo committed Dec 21, 2018
2 parents 7d523b0 + 0b29ed6 commit d79c212e7ba1e587826cf45b50750529c2ba88f0
Showing with 10 additions and 1 deletion.
  1. +8 −1 src/app/vertextool/qgsvertextool.cpp
  2. +2 −0 src/app/vertextool/qgsvertextool.h
@@ -984,7 +984,8 @@ QgsGeometry QgsVertexTool::cachedGeometry( const QgsVectorLayer *layer, QgsFeatu
{
connect( layer, &QgsVectorLayer::geometryChanged, this, &QgsVertexTool::onCachedGeometryChanged );
connect( layer, &QgsVectorLayer::featureDeleted, this, &QgsVertexTool::onCachedGeometryDeleted );
// TODO: also clear cache when layer is deleted
connect( layer, &QgsVectorLayer::willBeDeleted, this, &QgsVertexTool::clearGeometryCache );
connect( layer, &QgsVectorLayer::dataChanged, this, &QgsVertexTool::clearGeometryCache );
}

QHash<QgsFeatureId, QgsGeometry> &layerCache = mCache[layer];
@@ -1003,6 +1004,12 @@ QgsGeometry QgsVertexTool::cachedGeometryForVertex( const Vertex &vertex )
return cachedGeometry( vertex.layer, vertex.fid );
}

void QgsVertexTool::clearGeometryCache()
{
const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( sender() );
mCache.remove( layer );
}

void QgsVertexTool::onCachedGeometryChanged( QgsFeatureId fid, const QgsGeometry &geom )
{
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( sender() );
@@ -97,6 +97,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void onCachedGeometryDeleted( QgsFeatureId fid );

void clearGeometryCache();

void showVertexEditor(); //#spellok

void deleteVertexEditorSelection();

0 comments on commit d79c212

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