Skip to content

Commit

Permalink
Some fixes to processing expression parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 11, 2016
1 parent a4cc572 commit 28d7cea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions python/plugins/processing/core/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1251,12 +1251,13 @@ def getAsScriptCode(self):
@classmethod
def fromScriptCode(self, line):
isOptional, name, definition = _splitParameterOptions(line)
descName = _createDescriptiveName(name)
default = definition.strip()[len('expression') + 1:]
if default:
return ParameterExpression(name, descName, default, optional=isOptional)
else:
return ParameterExpression(name, descName, optional=isOptional)
if definition.lower().strip().startswith('expression'):
descName = _createDescriptiveName(name)
default = definition.strip()[len('expression') + 1:]
if default:
return ParameterExpression(name, descName, default, optional=isOptional)
else:
return ParameterExpression(name, descName, optional=isOptional)


class ParameterTable(ParameterDataObject):
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/processing/gui/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,10 @@ def setValue(self, value):

def value(self):
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
return self.widget.asExpression()
try:
return self.widget.asExpression()
except:
return self.widget.expression()
else:
def validator(v):
return bool(v) or self.param.optional
Expand Down

0 comments on commit 28d7cea

Please sign in to comment.