Skip to content
Permalink
Browse files

Autosave after successful check

  • Loading branch information
m-kuhn committed Oct 3, 2018
1 parent 417fa06 commit d527fed10aaa21de9ff6274fa84892ef6df6e0f0
Showing with 14 additions and 1 deletion.
  1. +12 −1 src/app/qgsgeometryvalidationservice.cpp
  2. +2 −0 src/app/qgsgeometryvalidationservice.h
@@ -139,6 +139,9 @@ void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer
{
emit warning( tr( "Can not save yet, we'll need to run some topology checks on your dataset first..." ) );
}

mLayerChecks[layer].commitPending = true;

triggerTopologyChecks( layer );
}
}
@@ -193,7 +196,7 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )
precision = 8;
}

checkInformation.context = qgis::make_unique<QgsGeometryCheckContext>( precision, mProject->crs(), mProject->transformContext() );
checkInformation.context = qgis::make_unique<QgsGeometryCheckContext>( 10, mProject->crs(), mProject->transformContext() );

QList<QgsGeometryCheck *> layerChecks;

@@ -311,6 +314,7 @@ void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFea
QgsFeature feature = layer->getFeature( fid );

const auto &checks = mLayerChecks[layer].singleFeatureChecks;
mLayerChecks[layer].singleFeatureCheckErrors.remove( fid );

// The errors are going to be sent out via a signal. We cannot keep ownership in here (or can we?)
// nor can we be sure that a single slot is connected to the signal. So make it a shared_ptr.
@@ -323,6 +327,9 @@ void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFea
allErrors.append( std::shared_ptr<QgsSingleGeometryCheckError>( error ) );
}

if ( !allErrors.empty() )
mLayerChecks[layer].singleFeatureCheckErrors.insert( fid, allErrors );

emit geometryCheckCompleted( layer, fid, allErrors );
}

@@ -408,6 +415,10 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer
futureWatcher->deleteLater();
if ( mLayerChecks[layer].topologyCheckFutureWatcher == futureWatcher )
mLayerChecks[layer].topologyCheckFutureWatcher = nullptr;

if ( allErrors.empty() && !mLayerChecks[layer].singleFeatureCheckErrors.empty() && mLayerChecks[layer].commitPending )
layer->commitChanges();
mLayerChecks[layer].commitPending = false;
} );

mLayerChecks[layer].topologyCheckFutureWatcher = futureWatcher;
@@ -98,12 +98,14 @@ class QgsGeometryValidationService : public QObject
struct VectorLayerCheckInformation
{
QList< QgsSingleGeometryCheck * > singleFeatureChecks;
QMap<QgsFeatureId, QList< std::shared_ptr<QgsSingleGeometryCheckError > > > singleFeatureCheckErrors;
QList< QgsGeometryCheck *> topologyChecks;
QFutureWatcher<void> *topologyCheckFutureWatcher = nullptr;
QList<QgsFeedback *> topologyCheckFeedbacks; // will be deleted when topologyCheckFutureWatcher is delteed
QList<std::shared_ptr<QgsGeometryCheckError>> topologyCheckErrors;
QList<QMetaObject::Connection> connections;
std::shared_ptr<QgsGeometryCheckContext> context;
bool commitPending = false;
};

QReadWriteLock mTopologyCheckLock;

0 comments on commit d527fed

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