Skip to content
Permalink
Browse files

Put topology check cancelation into its own routine

  • Loading branch information
m-kuhn committed Oct 1, 2018
1 parent fe5a80c commit 273d3c871860eb82b2b6f198ce5343d211618eb7
Showing with 25 additions and 19 deletions.
  1. +23 −19 src/app/qgsgeometryvalidationservice.cpp
  2. +2 −0 src/app/qgsgeometryvalidationservice.h
@@ -174,6 +174,27 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )
mLayerCheckStates[layer].topologyChecks = topologyChecks;
}

void QgsGeometryValidationService::cancelTopologyCheck( QgsVectorLayer *layer )
{
QFutureWatcher<void> *futureWatcher = mLayerCheckStates[layer].topologyCheckFutureWatcher;
if ( futureWatcher )
{
// Make sure no more checks are started first
futureWatcher->cancel();

// Tell all checks to stop asap
const auto feedbacks = mLayerCheckStates[layer].topologyCheckFeedbacks;
for ( QgsFeedback *feedback : feedbacks )
{
if ( feedback )
feedback->cancel();
}

futureWatcher->waitForFinished();
mLayerCheckStates[layer].topologyCheckFutureWatcher = nullptr;
}
}

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

@@ -204,24 +225,7 @@ void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFea
void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer )
{
emit topologyChecksCleared( layer );

QFutureWatcher<void> *futureWatcher = mLayerCheckStates[layer].topologyCheckFutureWatcher;
if ( futureWatcher )
{
// Make sure no more checks are started first
futureWatcher->cancel();

// Tell all checks to stop asap
const auto feedbacks = mLayerCheckStates[layer].topologyCheckFeedbacks;
for ( QgsFeedback *feedback : feedbacks )
{
if ( feedback )
feedback->cancel();
}

// The future watcher will take care of deleting
mLayerCheckStates[layer].topologyCheckFeedbacks.clear();
}
cancelTopologyCheck( layer );

QgsFeatureIds affectedFeatureIds = layer->editBuffer()->changedGeometries().keys().toSet();
affectedFeatureIds.unite( layer->editBuffer()->addedFeatures().keys().toSet() );
@@ -282,7 +286,7 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer
errorLocker.unlock();
} );

futureWatcher = new QFutureWatcher<void>();
QFutureWatcher<void> *futureWatcher = new QFutureWatcher<void>();
futureWatcher->setFuture( future );

connect( futureWatcher, &QFutureWatcherBase::finished, this, [&allErrors, layer, feedbacks, futureWatcher, this]()
@@ -87,6 +87,8 @@ class QgsGeometryValidationService : public QObject
private:
void enableLayerChecks( QgsVectorLayer *layer );

void cancelTopologyCheck( QgsVectorLayer *layer );

void cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid );

void processFeature( QgsVectorLayer *layer, QgsFeatureId fid );

0 comments on commit 273d3c8

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