Skip to content

Commit

Permalink
[processing] Fix optional layer parameters are filled by default
Browse files Browse the repository at this point in the history
Refs #17471

Not a full fix for 17471 - that requires handling of optional
numeric values too
  • Loading branch information
nyalldawson committed Dec 1, 2017
1 parent 0fcbeb7 commit 8303b94
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions python/plugins/processing/gui/wrappers.py
Expand Up @@ -708,8 +708,6 @@ def createWidget(self):
layout.addWidget(btn)

widget.setLayout(layout)
if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional:
self.combo.setAllowEmptyLayer(True)
if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF):
self.combo.setShowCrs(True)

Expand All @@ -720,6 +718,10 @@ def createWidget(self):
except:
pass

if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional:
self.combo.setAllowEmptyLayer(True)
self.combo.setLayer(None)

self.combo.currentIndexChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.combo.currentTextChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
return widget
Expand Down Expand Up @@ -907,15 +909,17 @@ def createWidget(self):
except:
pass

if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional:
self.combo.setAllowEmptyLayer(True)
if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF):
self.combo.setShowCrs(True)

if filters:
self.combo.setFilters(filters)
self.combo.setExcludedProviders(['grass'])

if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional:
self.combo.setAllowEmptyLayer(True)
self.combo.setLayer(None)

self.combo.layerChanged.connect(self.layerChanged)
return widget

Expand Down Expand Up @@ -1179,8 +1183,6 @@ def createWidget(self):

if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF):
self.combo.setShowCrs(True)
if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional:
self.combo.setAllowEmptyLayer(True)

filters = QgsMapLayerProxyModel.Filters()
if QgsProcessing.TypeVectorAnyGeometry in self.param.dataTypes() or len(self.param.dataTypes()) == 0:
Expand All @@ -1201,6 +1203,10 @@ def createWidget(self):
except:
pass

if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional:
self.combo.setAllowEmptyLayer(True)
self.combo.setLayer(None)

self.combo.currentIndexChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.combo.currentTextChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
return widget
Expand Down

0 comments on commit 8303b94

Please sign in to comment.