Skip to content
Permalink
Browse files

In batch mode, don't try to run rows with invalid parameter values

  • Loading branch information
github-actions authored and nyalldawson committed Mar 19, 2020
1 parent 4dbc64f commit a9a8684878d14b9a39abe750920a72e190158983
@@ -94,8 +94,11 @@ def runAlgorithm(self):
project = QgsProject.instance() if load_layers else None

for row in range(self.mainWidget().batchRowCount()):
parameters = self.mainWidget().parametersForRow(row, destinationProject=project, warnOnInvalid=True)
alg_parameters.append(parameters)
parameters, ok = self.mainWidget().parametersForRow(row, destinationProject=project, warnOnInvalid=True)
if ok:
alg_parameters.append(parameters)
if not alg_parameters:
return

task = QgsScopedProxyProgressTask(self.tr('Batch Processing - {0}').format(self.algorithm().displayName()))
multi_feedback = BatchFeedback(len(alg_parameters), feedback)
@@ -210,7 +210,7 @@ def populateByExpression(self, adding=False):
expression_context = context.expressionContext()

# use the first row parameter values as a preview during expression creation
params = self.panel.parametersForRow(0, warnOnInvalid=False)
params, ok = self.panel.parametersForRow(0, warnOnInvalid=False)
alg_scope = QgsExpressionContextUtils.processingAlgorithmScope(self.panel.alg, params, context)

# create explicit variables corresponding to every parameter
@@ -247,7 +247,7 @@ def populateByExpression(self, adding=False):
self.setRowValue(row + first_row, value, context)
else:
for row in range(self.panel.batchRowCount()):
params = self.panel.parametersForRow(row, warnOnInvalid=False)
params, ok = self.panel.parametersForRow(row, warnOnInvalid=False)

# remove previous algorithm scope -- we need to rebuild this completely, using the
# other parameter values from the current row
@@ -597,7 +597,7 @@ def parametersForRow(self, row, destinationProject=None, warnOnInvalid=True):
self.tr('Wrong or missing parameter value: {0} (row {1})').format(
param.description(), row + 1),
level=Qgis.Warning, duration=5)
return {}
return {}, False
col += 1
count_visible_outputs = 0
for out in self.alg.destinationParameterDefinitions():
@@ -620,5 +620,5 @@ def parametersForRow(self, row, destinationProject=None, warnOnInvalid=True):
self.parent.messageBar().pushMessage("", self.tr('Wrong or missing output value: {0} (row {1})').format(
out.description(), row + 1),
level=Qgis.Warning, duration=5)
return {}
return parameters
return {}, False
return parameters, True

0 comments on commit a9a8684

Please sign in to comment.
You can’t perform that action at this time.