mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Don't throw python exception when modeler algorithm is missing inputs
Instead use nicer messagebar for feedback. Also fix untranslatable strings. Refs #17028
This commit is contained in:
parent
367aba7059
commit
cdbb57d65f
@ -303,7 +303,13 @@ class ModelerParametersDialog(QDialog):
|
|||||||
for param in self._alg.parameterDefinitions():
|
for param in self._alg.parameterDefinitions():
|
||||||
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
|
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
|
||||||
continue
|
continue
|
||||||
val = self.wrappers[param.name()].value()
|
try:
|
||||||
|
val = self.wrappers[param.name()].value()
|
||||||
|
except InvalidParameterValue:
|
||||||
|
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
|
||||||
|
level=QgsMessageBar.WARNING)
|
||||||
|
return None
|
||||||
|
|
||||||
if isinstance(val, QgsProcessingModelChildParameterSource):
|
if isinstance(val, QgsProcessingModelChildParameterSource):
|
||||||
val = [val]
|
val = [val]
|
||||||
elif not (isinstance(val, list) and all([isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
|
elif not (isinstance(val, list) and all([isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
|
||||||
@ -313,7 +319,7 @@ class ModelerParametersDialog(QDialog):
|
|||||||
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
|
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
|
||||||
not param.checkValueIsAcceptable(subval.staticValue())) \
|
not param.checkValueIsAcceptable(subval.staticValue())) \
|
||||||
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
|
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
|
||||||
self.bar.pushMessage("Error", "Wrong or missing value for parameter '%s'" % param.description(),
|
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
|
||||||
level=QgsMessageBar.WARNING)
|
level=QgsMessageBar.WARNING)
|
||||||
return None
|
return None
|
||||||
alg.addParameterSources(param.name(), val)
|
alg.addParameterSources(param.name(), val)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user