Skip to content

Commit f476fe7

Browse files
committedApr 14, 2020
[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...
1 parent 9f7c7fc commit f476fe7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
 

‎python/plugins/processing/modeler/ModelerParametersDialog.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,26 +460,25 @@ def createAlgorithm(self):
460460
else:
461461
val = wrapper.parameterValue()
462462
except InvalidParameterValue:
463-
self.bar.pushMessage(self.tr("Error"),
464-
self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
465-
level=Qgis.Warning)
466-
return None
463+
val = None
467464

468465
if isinstance(val, QgsProcessingModelChildParameterSource):
469466
val = [val]
470467
elif not (isinstance(val, list) and all(
471468
[isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
472469
val = [QgsProcessingModelChildParameterSource.fromStaticValue(val)]
470+
471+
valid = True
473472
for subval in val:
474473
if (isinstance(subval, QgsProcessingModelChildParameterSource) and
475474
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
476475
not param.checkValueIsAcceptable(subval.staticValue())) \
477476
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
478-
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(
479-
param.description()),
480-
level=Qgis.Warning)
481-
return None
482-
alg.addParameterSources(param.name(), val)
477+
valid = False
478+
break
479+
480+
if valid:
481+
alg.addParameterSources(param.name(), val)
483482

484483
outputs = {}
485484
for output in self._alg.destinationParameterDefinitions():

0 commit comments

Comments
 (0)
Please sign in to comment.