Skip to content

Commit 8e3e30a

Browse files
committedApr 27, 2017
[processing] prevent division by zero in save selected features
algorithm (fix #16431)
1 parent 0125a36 commit 8e3e30a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎python/plugins/processing/algs/qgis/SaveSelectedFeatures.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
__revision__ = '$Format:%H$'
2727

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

5859
features = vectorLayer.selectedFeaturesIterator()
60+
if vectorLayer.selectedFeatureCount() == 0:
61+
raise GeoAlgorithmExecutionException(self.tr('There are no selected features in the input layer.'))
62+
5963
total = 100.0 / int(vectorLayer.selectedFeatureCount())
6064
for current, feat in enumerate(features):
6165
writer.addFeature(feat)

0 commit comments

Comments
 (0)
Please sign in to comment.