Skip to content

Commit b637c7f

Browse files
committed
Prevent background execution of zonal stats
This algorithm is NEVER safe to run in the background, because it directly modifies a layer in place. We should: - make a variant of this algorithm which returns a new layer AND - refactor the QgsZonalStats code to create a separate map of feature->stats, and then modify the existing Zonal Stats algorithm to apply these changes in a post processing step
1 parent 6bf7c0e commit b637c7f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/plugins/processing/algs/qgis/ZonalStatistics.py

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from qgis.analysis import QgsZonalStatistics
3434
from qgis.core import (QgsProcessing,
35+
QgsProcessingAlgorithm,
3536
QgsProcessingParameterVectorLayer,
3637
QgsProcessingParameterRasterLayer,
3738
QgsProcessingParameterString,
@@ -61,6 +62,9 @@ def group(self):
6162
def groupId(self):
6263
return 'rasteranalysis'
6364

65+
def flags(self):
66+
return super().flags() | QgsProcessingAlgorithm.FlagNoThreading
67+
6468
def __init__(self):
6569
super().__init__()
6670
self.bandNumber = None

0 commit comments

Comments
 (0)