Skip to content

Commit

Permalink
Improve fixError
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent fff52c7 commit d0d08cc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
33 changes: 30 additions & 3 deletions src/app/qgsgeometryvalidationservice.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsgeometryvalidationservice.h
Expand Up @@ -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 );

Expand Down

0 comments on commit d0d08cc

Please sign in to comment.