Skip to content

Commit

Permalink
[processing] fix handling of optional string arguments (fix #9109, 9120)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 26, 2014
1 parent 92ee039 commit 024f6a1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/plugins/processing/gdal/ClipByExtent.py
Expand Up @@ -60,7 +60,7 @@ def defineCharacteristics(self):
'none'))
self.addParameter(ParameterExtent(self.PROJWIN, 'Clipping extent'))
self.addParameter(ParameterString(self.EXTRA,
'Additional creation parameters', ''))
'Additional creation parameters', '', optional=True))
self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))

def processAlgorithm(self, progress):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gdal/ClipByMask.py
Expand Up @@ -70,7 +70,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterBoolean(self.KEEP_RESOLUTION,
'Keep resolution of output raster', False))
self.addParameter(ParameterString(self.EXTRA,
'Additional creation parameters', ''))
'Additional creation parameters', '', optional=True))
self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))

def processAlgorithm(self, progress):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gdal/contour.py
Expand Up @@ -64,7 +64,7 @@ def defineCharacteristics(self):
'Attribute name (if not set, no elevation attribute is attached)',
'ELEV', optional=True))
self.addParameter(ParameterString(self.EXTRA,
'Additional creation parameters', ''))
'Additional creation parameters', '', optional=True))

self.addOutput(OutputVector(self.OUTPUT_VECTOR,
'Output file for contour lines (vector)'))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gdal/translate.py
Expand Up @@ -84,7 +84,7 @@ def defineCharacteristics(self):
'Copy all subdatasets of this file to individual output files',
False))
self.addParameter(ParameterString(self.EXTRA,
'Additional creation parameters', ''))
'Additional creation parameters', '', optional=True))
self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))

def processAlgorithm(self, progress):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gdal/warp.py
Expand Up @@ -67,7 +67,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.METHOD, 'Resampling method',
self.METHOD_OPTIONS))
self.addParameter(ParameterString(self.EXTRA,
'Additional creation parameters', ''))
'Additional creation parameters', '', optional=True))
self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))

def processAlgorithm(self, progress):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/modeler/ModelerParametersDialog.py
Expand Up @@ -745,8 +745,8 @@ def setParamStringValue(self, param, widget):
else:
self.params[param.name] = value
else:
if widget.currentText() == '':
return False
#if widget.currentText() == '':
# return False
idx = widget.findText(widget.currentText())
if idx < 0:
name = self.getSafeNameForHarcodedParameter(param)
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/parameters/ParameterString.py
Expand Up @@ -43,6 +43,9 @@ def __init__(self, name='', description='', default='', multiline=False,

def setValue(self, obj):
if obj is None:
if self.optional:
self.value = ''
return True
self.value = self.default
return True
self.value = unicode(obj).replace(ParameterString.ESCAPED_NEWLINE,
Expand Down

0 comments on commit 024f6a1

Please sign in to comment.