Skip to content

Commit 55108ae

Browse files
committedApr 28, 2015
[processing] enabled inut checks for field calculator algorithm
fixes #12586
1 parent 2950146 commit 55108ae

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed
 

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,13 @@ def processAlgorithm(self, progress):
147147

148148
def checkParameterValuesBeforeExecuting(self):
149149
newField = self.getParameterValue(self.NEW_FIELD)
150-
fieldName = self.getParameterValue(self.FIELD_NAME)
150+
fieldName = self.getParameterValue(self.FIELD_NAME).strip()
151151
if newField and len(fieldName) == 0:
152-
raise GeoAlgorithmExecutionException(
153-
self.tr('Field name is not set. Please enter a field name'))
152+
return self.tr('Field name is not set. Please enter a field name')
154153

155-
outputName = self.getOutputValue(self.OUTPUT_LAYER)
154+
outputName = self.getOutputValue(self.OUTPUT_LAYER).strip()
156155
if outputName == '':
157-
raise GeoAlgorithmExecutionException(
158-
self.tr('Output is not set. Please specify valid filename'))
156+
return self.tr('Output is not set. Please specify valid filename')
159157

160158
def getCustomParametersDialog(self):
161159
return FieldsCalculatorDialog(self)

‎python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ def setParamValues(self):
182182
self.alg.setParameterValue('FORMULA', self.builder.expressionText())
183183
self.alg.setOutputValue('OUTPUT_LAYER',
184184
self.leOutputFile.text())
185+
186+
msg = self.alg.checkParameterValuesBeforeExecuting()
187+
if msg:
188+
QMessageBox.warning(
189+
self, self.tr('Unable to execute algorithm'), msg)
190+
return False
185191
return True
186192

187193
def accept(self):
@@ -199,11 +205,6 @@ def accept(self):
199205
not keepOpen)
200206
if not keepOpen:
201207
QDialog.reject(self)
202-
else:
203-
QMessageBox.critical(self,
204-
self.tr('Unable to execute algorithm'),
205-
self.tr('Wrong or missing parameter '
206-
'values'))
207208
finally:
208209
QApplication.restoreOverrideCursor()
209210

0 commit comments

Comments
 (0)
Please sign in to comment.