Skip to content

Commit

Permalink
[processing] prevent division by zero in save selected features
Browse files Browse the repository at this point in the history
algorithm (fix #16431)
  • Loading branch information
alexbruy committed Apr 27, 2017
1 parent 0125a36 commit 8e3e30a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/qgis/SaveSelectedFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e3e30a

Please sign in to comment.