Skip to content

Commit

Permalink
Centralize invalidateTopologyChecks handling
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent 97a9659 commit f3261e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions src/app/qgsgeometryvalidationservice.cpp
Expand Up @@ -63,34 +63,37 @@ void QgsGeometryValidationService::onFeatureAdded( QgsVectorLayer *layer, QgsFea
{ {
if ( !mLayerChecks[layer].topologyChecks.empty() ) if ( !mLayerChecks[layer].topologyChecks.empty() )
{ {
// TODO: Cancel topology checks invalidateTopologyChecks( layer );
layer->setAllowCommit( false );
} }
processFeature( layer, fid ); processFeature( layer, fid );
} }


void QgsGeometryValidationService::onGeometryChanged( QgsVectorLayer *layer, QgsFeatureId fid, const QgsGeometry &geometry ) void QgsGeometryValidationService::onGeometryChanged( QgsVectorLayer *layer, QgsFeatureId fid, const QgsGeometry &geometry )
{ {
Q_UNUSED( geometry )
// It would be nice to use the geometry here for the tests.
// But:
// 1. other codepaths to the checks also have no geometry (feature added / feature deleted)
// 2. and looking it up from the edit buffer (in memory) is really fast.
// so in short: it's still a good idea, but not as important as on first thought.

if ( !mLayerChecks[layer].topologyChecks.empty() ) if ( !mLayerChecks[layer].topologyChecks.empty() )
{ {
// TODO: Cancel topology checks invalidateTopologyChecks( layer );
layer->setAllowCommit( false );
} }
Q_UNUSED( geometry )


cancelChecks( layer, fid );
processFeature( layer, fid ); processFeature( layer, fid );
} }


void QgsGeometryValidationService::onFeatureDeleted( QgsVectorLayer *layer, QgsFeatureId fid ) void QgsGeometryValidationService::onFeatureDeleted( QgsVectorLayer *layer, QgsFeatureId fid )
{ {
if ( !mLayerChecks[layer].topologyChecks.empty() ) if ( !mLayerChecks[layer].topologyChecks.empty() )
{ {
// TODO: Cancel topology checks invalidateTopologyChecks( layer );
layer->setAllowCommit( false );
} }


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


void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer ) void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer )
Expand Down Expand Up @@ -220,9 +223,10 @@ void QgsGeometryValidationService::cancelTopologyCheck( QgsVectorLayer *layer )
} }
} }


void QgsGeometryValidationService::cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid ) void QgsGeometryValidationService::invalidateTopologyChecks( QgsVectorLayer *layer )
{ {

cancelTopologyCheck( layer );
layer->setAllowCommit( false );
} }


void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFeatureId fid ) void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFeatureId fid )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsgeometryvalidationservice.h
Expand Up @@ -84,7 +84,7 @@ class QgsGeometryValidationService : public QObject


void cancelTopologyCheck( QgsVectorLayer *layer ); void cancelTopologyCheck( QgsVectorLayer *layer );


void cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid ); void invalidateTopologyChecks( QgsVectorLayer *layer );


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


Expand Down

0 comments on commit f3261e1

Please sign in to comment.