mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[Processing] Improve the robustness of models when the parameters in the included algorithms change
This commit is contained in:
parent
7019db8831
commit
d1985b3d34
@ -35,6 +35,8 @@ import traceback
|
||||
from PyQt4.QtCore import QCoreApplication, QPointF
|
||||
from PyQt4.QtGui import QIcon
|
||||
from qgis.core import QgsRasterLayer, QgsVectorLayer
|
||||
from qgis.gui import QgsMessageBar
|
||||
from qgis.utils import iface
|
||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||
from processing.modeler.WrongModelException import WrongModelException
|
||||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||
@ -332,7 +334,13 @@ class ModelerAlgorithm(GeoAlgorithm):
|
||||
algInstance = alg.algorithm
|
||||
for param in algInstance.parameters:
|
||||
if not param.hidden:
|
||||
value = self.resolveValue(alg.params[param.name])
|
||||
if param.name in alg.params:
|
||||
value = self.resolveValue(alg.params[param.name])
|
||||
else:
|
||||
iface.messageBar().pushMessage(self.tr("Warning"),
|
||||
self.tr("Parameter %s in algorithm %s in the model is run with default value! Edit the model to make sure that this is correct." % (param.name, alg.name)),
|
||||
QgsMessageBar.WARNING, 4)
|
||||
value = None
|
||||
if value is None and isinstance(param, ParameterExtent):
|
||||
value = self.getMinCoveringExtent()
|
||||
# We allow unexistent filepaths, since that allows
|
||||
|
@ -410,7 +410,10 @@ class ModelerParametersDialog(QDialog):
|
||||
if param.hidden:
|
||||
continue
|
||||
widget = self.valueItems[param.name]
|
||||
value = alg.params[param.name]
|
||||
if param.name in alg.params:
|
||||
value = alg.params[param.name]
|
||||
else:
|
||||
value = None
|
||||
if isinstance(param, (
|
||||
ParameterRaster,
|
||||
ParameterVector,
|
||||
|
@ -98,7 +98,10 @@ class ModelerScene(QtGui.QGraphicsScene):
|
||||
idx = 0
|
||||
for parameter in alg.algorithm.parameters:
|
||||
if not parameter.hidden:
|
||||
value = alg.params[parameter.name]
|
||||
if parameter.name in alg.params:
|
||||
value = alg.params[parameter.name]
|
||||
else:
|
||||
value = None
|
||||
sourceItems = self.getItemsFromParamValue(value)
|
||||
for sourceItem, sourceIdx in sourceItems:
|
||||
arrow = ModelerArrowItem(sourceItem, sourceIdx, self.algItems[alg.name], idx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user