From f476fe7fc42a820e5ba9988ddffe2f1885689726 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 14 Apr 2020 15:46:38 +1000 Subject: [PATCH] [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... --- .../modeler/ModelerParametersDialog.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/python/plugins/processing/modeler/ModelerParametersDialog.py b/python/plugins/processing/modeler/ModelerParametersDialog.py index ad2ae70f708..3edc731e64f 100644 --- a/python/plugins/processing/modeler/ModelerParametersDialog.py +++ b/python/plugins/processing/modeler/ModelerParametersDialog.py @@ -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():