Skip to content
Permalink
Browse files

Improve fixError

  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent fff52c7 commit d0d08ccf396f0860488fa1d86021fd4f4ba40e0c
Showing with 31 additions and 4 deletions.
  1. +30 −3 src/app/qgsgeometryvalidationservice.cpp
  2. +1 −1 src/app/qgsgeometryvalidationservice.h
@@ -35,11 +35,38 @@ QgsGeometryValidationService::QgsGeometryValidationService( QgsProject *project
connect( project, &QgsProject::layersAdded, this, &QgsGeometryValidationService::onLayersAdded );
}

void QgsGeometryValidationService::fixError( const QgsGeometryCheckError *error, int method )
void QgsGeometryValidationService::fixError( QgsGeometryCheckError *error, int method )
{
QgsGeometryCheck::Changes changes;
QgsGeometryCheckError *nonconsterr = const_cast<QgsGeometryCheckError *>( error );
error->check()->fixError( mFeaturePools, nonconsterr, method, QMap<QString, int>(), changes );
error->check()->fixError( mFeaturePools, error, method, QMap<QString, int>(), changes );
error->setFixed( method );

QgsFeaturePool *featurePool = mFeaturePools.value( error->layerId() );

QgsVectorLayer *layer;

if ( featurePool )
layer = featurePool->layer();
else
{
// Some checks don't tell us on which layer they are because they are able to do cross-layer checks.
// E.g. the gap check will report in such a way

for ( auto layerCheck = mLayerChecks.constBegin(); layerCheck != mLayerChecks.constEnd(); ++layerCheck )
{
const QList<std::shared_ptr<QgsGeometryCheckError>> &topologyCheckErrors = layerCheck.value().topologyCheckErrors;
for ( const auto &checkError : topologyCheckErrors )
{
if ( checkError.get() == error )
{
layer = layerCheck.key();
break;
}
}
}
}

emit topologyErrorUpdated( layer, error );
}

void QgsGeometryValidationService::onLayersAdded( const QList<QgsMapLayer *> &layers )
@@ -60,7 +60,7 @@ class QgsGeometryValidationService : public QObject
QgsGeometryValidationService( QgsProject *project );
~QgsGeometryValidationService() = default;

void fixError( const QgsGeometryCheckError *error, int method );
void fixError( QgsGeometryCheckError *error, int method );

void triggerTopologyChecks( QgsVectorLayer *layer );

0 comments on commit d0d08cc

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