@@ -174,6 +174,27 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )
174
174
mLayerCheckStates [layer].topologyChecks = topologyChecks;
175
175
}
176
176
177
+ void QgsGeometryValidationService::cancelTopologyCheck ( QgsVectorLayer *layer )
178
+ {
179
+ QFutureWatcher<void > *futureWatcher = mLayerCheckStates [layer].topologyCheckFutureWatcher ;
180
+ if ( futureWatcher )
181
+ {
182
+ // Make sure no more checks are started first
183
+ futureWatcher->cancel ();
184
+
185
+ // Tell all checks to stop asap
186
+ const auto feedbacks = mLayerCheckStates [layer].topologyCheckFeedbacks ;
187
+ for ( QgsFeedback *feedback : feedbacks )
188
+ {
189
+ if ( feedback )
190
+ feedback->cancel ();
191
+ }
192
+
193
+ futureWatcher->waitForFinished ();
194
+ mLayerCheckStates [layer].topologyCheckFutureWatcher = nullptr ;
195
+ }
196
+ }
197
+
177
198
void QgsGeometryValidationService::cancelChecks ( QgsVectorLayer *layer, QgsFeatureId fid )
178
199
{
179
200
@@ -204,24 +225,7 @@ void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFea
204
225
void QgsGeometryValidationService::triggerTopologyChecks ( QgsVectorLayer *layer )
205
226
{
206
227
emit topologyChecksCleared ( layer );
207
-
208
- QFutureWatcher<void > *futureWatcher = mLayerCheckStates [layer].topologyCheckFutureWatcher ;
209
- if ( futureWatcher )
210
- {
211
- // Make sure no more checks are started first
212
- futureWatcher->cancel ();
213
-
214
- // Tell all checks to stop asap
215
- const auto feedbacks = mLayerCheckStates [layer].topologyCheckFeedbacks ;
216
- for ( QgsFeedback *feedback : feedbacks )
217
- {
218
- if ( feedback )
219
- feedback->cancel ();
220
- }
221
-
222
- // The future watcher will take care of deleting
223
- mLayerCheckStates [layer].topologyCheckFeedbacks .clear ();
224
- }
228
+ cancelTopologyCheck ( layer );
225
229
226
230
QgsFeatureIds affectedFeatureIds = layer->editBuffer ()->changedGeometries ().keys ().toSet ();
227
231
affectedFeatureIds.unite ( layer->editBuffer ()->addedFeatures ().keys ().toSet () );
@@ -282,7 +286,7 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer
282
286
errorLocker.unlock ();
283
287
} );
284
288
285
- futureWatcher = new QFutureWatcher<void >();
289
+ QFutureWatcher< void > * futureWatcher = new QFutureWatcher<void >();
286
290
futureWatcher->setFuture ( future );
287
291
288
292
connect ( futureWatcher, &QFutureWatcherBase::finished, this , [&allErrors, layer, feedbacks, futureWatcher, this ]()
0 commit comments