@@ -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
4572void QgsGeometryValidationService::onLayersAdded ( const QList<QgsMapLayer *> &layers )
0 commit comments