Skip to content

Commit

Permalink
Merge pull request #8724 from mhugo/fix_vertex_tool_cache
Browse files Browse the repository at this point in the history
Fix vertextool's geometry cache invalidation
  • Loading branch information
Hugo Mercier committed Dec 21, 2018
2 parents 7d523b0 + 0b29ed6 commit d79c212
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -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];
Expand All @@ -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() );
Expand Down
2 changes: 2 additions & 0 deletions src/app/vertextool/qgsvertextool.h
Expand Up @@ -97,6 +97,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void onCachedGeometryDeleted( QgsFeatureId fid );

void clearGeometryCache();

void showVertexEditor(); //#spellok

void deleteVertexEditorSelection();
Expand Down

0 comments on commit d79c212

Please sign in to comment.