[processing] Don't force a child algorithm in a model to have all valid 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...
This commit is contained in:
Nyall Dawson 2020-04-14 15:46:38 +10:00
parent 9f7c7fcb35
commit f476fe7fc4

View File

@ -460,26 +460,25 @@ class ModelerParametersPanelWidget(QgsPanelWidget):
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():