Skip to content
Permalink
Browse files

[processing] Fix optional layer parameters are filled by default

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 8303b9468512563979f931652d07ef873e458c9f
Showing with 12 additions and 6 deletions.
  1. +12 −6 python/plugins/processing/gui/wrappers.py
@@ -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)

@@ -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
@@ -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

@@ -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:
@@ -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

0 comments on commit 8303b94

Please sign in to comment.
You can’t perform that action at this time.