Skip to content

Commit

Permalink
In batch mode, don't try to run rows with invalid parameter values
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Mar 20, 2020
1 parent 08f4f9c commit f5c1d22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions python/plugins/processing/gui/BatchAlgorithmDialog.py
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/gui/BatchPanel.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -600,7 +600,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():
Expand All @@ -623,5 +623,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 f5c1d22

Please sign in to comment.