Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Don't force a child algorithm in a model to have all val…
…id values upfront

This allows defered setting of parameter values, e.g. if you add an algorithm, fill in
half the parameter values, then realise you need to add a new input to the model, you
don't have to lose all your filled in values...
  • Loading branch information
nyalldawson committed Apr 14, 2020
1 parent 9f7c7fc commit f476fe7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions python/plugins/processing/modeler/ModelerParametersDialog.py
Expand Up @@ -460,26 +460,25 @@ def createAlgorithm(self):
else:
val = wrapper.parameterValue()
except InvalidParameterValue:
self.bar.pushMessage(self.tr("Error"),
self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
level=Qgis.Warning)
return None
val = None

if isinstance(val, QgsProcessingModelChildParameterSource):
val = [val]
elif not (isinstance(val, list) and all(
[isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
val = [QgsProcessingModelChildParameterSource.fromStaticValue(val)]

valid = True
for subval in val:
if (isinstance(subval, QgsProcessingModelChildParameterSource) and
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
not param.checkValueIsAcceptable(subval.staticValue())) \
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(
param.description()),
level=Qgis.Warning)
return None
alg.addParameterSources(param.name(), val)
valid = False
break

if valid:
alg.addParameterSources(param.name(), val)

outputs = {}
for output in self._alg.destinationParameterDefinitions():
Expand Down

0 comments on commit f476fe7

Please sign in to comment.