Skip to content

Commit f3261e1

Browse files
committed
Centralize invalidateTopologyChecks handling
1 parent 97a9659 commit f3261e1

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/app/qgsgeometryvalidationservice.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,37 @@ void QgsGeometryValidationService::onFeatureAdded( QgsVectorLayer *layer, QgsFea
6363
{
6464
if ( !mLayerChecks[layer].topologyChecks.empty() )
6565
{
66-
// TODO: Cancel topology checks
67-
layer->setAllowCommit( false );
66+
invalidateTopologyChecks( layer );
6867
}
6968
processFeature( layer, fid );
7069
}
7170

7271
void QgsGeometryValidationService::onGeometryChanged( QgsVectorLayer *layer, QgsFeatureId fid, const QgsGeometry &geometry )
7372
{
73+
Q_UNUSED( geometry )
74+
// It would be nice to use the geometry here for the tests.
75+
// But:
76+
// 1. other codepaths to the checks also have no geometry (feature added / feature deleted)
77+
// 2. and looking it up from the edit buffer (in memory) is really fast.
78+
// so in short: it's still a good idea, but not as important as on first thought.
79+
7480
if ( !mLayerChecks[layer].topologyChecks.empty() )
7581
{
76-
// TODO: Cancel topology checks
77-
layer->setAllowCommit( false );
82+
invalidateTopologyChecks( layer );
7883
}
79-
Q_UNUSED( geometry )
8084

81-
cancelChecks( layer, fid );
8285
processFeature( layer, fid );
8386
}
8487

8588
void QgsGeometryValidationService::onFeatureDeleted( QgsVectorLayer *layer, QgsFeatureId fid )
8689
{
8790
if ( !mLayerChecks[layer].topologyChecks.empty() )
8891
{
89-
// TODO: Cancel topology checks
90-
layer->setAllowCommit( false );
92+
invalidateTopologyChecks( layer );
9193
}
9294

93-
cancelChecks( layer, fid );
95+
// There should be no geometry errors on an inexistent feature, right?
96+
emit geometryCheckCompleted( layer, fid, QList<std::shared_ptr<QgsSingleGeometryCheckError>>() );
9497
}
9598

9699
void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer )
@@ -220,9 +223,10 @@ void QgsGeometryValidationService::cancelTopologyCheck( QgsVectorLayer *layer )
220223
}
221224
}
222225

223-
void QgsGeometryValidationService::cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid )
226+
void QgsGeometryValidationService::invalidateTopologyChecks( QgsVectorLayer *layer )
224227
{
225-
228+
cancelTopologyCheck( layer );
229+
layer->setAllowCommit( false );
226230
}
227231

228232
void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFeatureId fid )

src/app/qgsgeometryvalidationservice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class QgsGeometryValidationService : public QObject
8484

8585
void cancelTopologyCheck( QgsVectorLayer *layer );
8686

87-
void cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid );
87+
void invalidateTopologyChecks( QgsVectorLayer *layer );
8888

8989
void processFeature( QgsVectorLayer *layer, QgsFeatureId fid );
9090

0 commit comments

Comments
 (0)