Skip to content

Commit d0d08cc

Browse files
committedOct 15, 2018
Improve fixError
1 parent fff52c7 commit d0d08cc

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed
 

‎src/app/qgsgeometryvalidationservice.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,38 @@ QgsGeometryValidationService::QgsGeometryValidationService( QgsProject *project
3535
connect( project, &QgsProject::layersAdded, this, &QgsGeometryValidationService::onLayersAdded );
3636
}
3737

38-
void QgsGeometryValidationService::fixError( const QgsGeometryCheckError *error, int method )
38+
void QgsGeometryValidationService::fixError( QgsGeometryCheckError *error, int method )
3939
{
4040
QgsGeometryCheck::Changes changes;
41-
QgsGeometryCheckError *nonconsterr = const_cast<QgsGeometryCheckError *>( error );
42-
error->check()->fixError( mFeaturePools, nonconsterr, method, QMap<QString, int>(), changes );
41+
error->check()->fixError( mFeaturePools, error, method, QMap<QString, int>(), changes );
42+
error->setFixed( method );
43+
44+
QgsFeaturePool *featurePool = mFeaturePools.value( error->layerId() );
45+
46+
QgsVectorLayer *layer;
47+
48+
if ( featurePool )
49+
layer = featurePool->layer();
50+
else
51+
{
52+
// Some checks don't tell us on which layer they are because they are able to do cross-layer checks.
53+
// E.g. the gap check will report in such a way
54+
55+
for ( auto layerCheck = mLayerChecks.constBegin(); layerCheck != mLayerChecks.constEnd(); ++layerCheck )
56+
{
57+
const QList<std::shared_ptr<QgsGeometryCheckError>> &topologyCheckErrors = layerCheck.value().topologyCheckErrors;
58+
for ( const auto &checkError : topologyCheckErrors )
59+
{
60+
if ( checkError.get() == error )
61+
{
62+
layer = layerCheck.key();
63+
break;
64+
}
65+
}
66+
}
67+
}
68+
69+
emit topologyErrorUpdated( layer, error );
4370
}
4471

4572
void QgsGeometryValidationService::onLayersAdded( const QList<QgsMapLayer *> &layers )

‎src/app/qgsgeometryvalidationservice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class QgsGeometryValidationService : public QObject
6060
QgsGeometryValidationService( QgsProject *project );
6161
~QgsGeometryValidationService() = default;
6262

63-
void fixError( const QgsGeometryCheckError *error, int method );
63+
void fixError( QgsGeometryCheckError *error, int method );
6464

6565
void triggerTopologyChecks( QgsVectorLayer *layer );
6666

0 commit comments

Comments
 (0)
Please sign in to comment.