Skip to content

Commit

Permalink
Make model editor dialog more robust while loading models
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 8, 2017
1 parent 9d04f87 commit 0836c60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python/plugins/processing/gui/wrappers.py
Expand Up @@ -177,7 +177,10 @@ def setComboValue(self, value, combobox=None):
if combobox is None:
combobox = self.widget
if isinstance(value, list):
value = value[0]
if value:
value = value[0]
else:
value = None
values = [combobox.itemData(i) for i in range(combobox.count())]
try:
idx = values.index(value)
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/processing/modeler/ModelerParametersDialog.py
Expand Up @@ -251,11 +251,14 @@ def setPreviousValues(self):
for param in alg.algorithm().parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
value = None
if param.name() in alg.parameterSources():
value = alg.parameterSources()[param.name()]
if isinstance(value, list) and len(value) == 1:
value = value[0]
else:
elif isinstance(value, list) and len(value) == 0:
value = None
if value is None:
value = param.defaultValue()

if isinstance(value, QgsProcessingModelAlgorithm.ChildParameterSource) and value.source() == QgsProcessingModelAlgorithm.ChildParameterSource.StaticValue:
Expand Down

0 comments on commit 0836c60

Please sign in to comment.