Skip to content
Permalink
Browse files
[processing] prevent division by zero in save selected features
algorithm (fix #16431)
  • Loading branch information
alexbruy committed Apr 27, 2017
1 parent 0125a36 commit 8e3e30a20e4fdff6091da1d56a385edff62bd30e
Showing with 4 additions and 0 deletions.
  1. +4 −0 python/plugins/processing/algs/qgis/SaveSelectedFeatures.py
@@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
from processing.tools import dataobjects
@@ -56,6 +57,9 @@ def processAlgorithm(self, progress):
vectorLayer.wkbType(), vectorLayer.crs())

features = vectorLayer.selectedFeaturesIterator()
if vectorLayer.selectedFeatureCount() == 0:
raise GeoAlgorithmExecutionException(self.tr('There are no selected features in the input layer.'))

total = 100.0 / int(vectorLayer.selectedFeatureCount())
for current, feat in enumerate(features):
writer.addFeature(feat)

0 comments on commit 8e3e30a

Please sign in to comment.