Skip to content
Permalink
Browse files

Fix exception in test

  • Loading branch information
nyalldawson committed Mar 25, 2020
1 parent 6ac9fca commit 44ae5a5e1d481da51c750382dabfbab9c31ada04
Showing with 12 additions and 8 deletions.
  1. +12 −8 python/plugins/processing/gui/wrappers.py
@@ -1141,20 +1141,24 @@ def value(self):
class FeatureSourceWidgetWrapper(WidgetWrapper):
NOT_SELECTED = '[Not selected]'

def __init__(self, *args, **kwargs):
self.map_layer_combo = None
super().__init__(*args, **kwargs)

def createWidget(self):
if self.dialogType == DIALOG_STANDARD:
self.combo = QgsProcessingMapLayerComboBox(self.parameterDefinition())
self.map_layer_combo = QgsProcessingMapLayerComboBox(self.parameterDefinition())
self.context = dataobjects.createContext()

try:
if iface.activeLayer().type() == QgsMapLayerType.VectorLayer:
self.combo.setLayer(iface.activeLayer())
self.map_layer_combo.setLayer(iface.activeLayer())
except:
pass

self.combo.valueChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.map_layer_combo.valueChanged.connect(lambda: self.widgetValueHasChanged.emit(self))

return self.combo
return self.map_layer_combo

elif self.dialogType == DIALOG_BATCH:
widget = BatchInputSelectionPanel(self.parameterDefinition(), self.row, self.col, self.dialog)
@@ -1186,8 +1190,8 @@ def createWidget(self):
return widget

def setWidgetContext(self, context):
if isinstance(self.combo, QgsProcessingMapLayerComboBox):
self.combo.setWidgetContext(context)
if self.map_layer_combo:
self.map_layer_combo.setWidgetContext(context)
super().setWidgetContext(context)

def selectFile(self):
@@ -1213,7 +1217,7 @@ def setValue(self, value):
layer = QgsProject.instance().mapLayer(value)
if layer is not None:
value = layer
self.combo.setValue(value, self.context)
self.map_layer_combo.setValue(value, self.context)
elif self.dialogType == DIALOG_BATCH:
self.widget.setValue(value)
else:
@@ -1222,7 +1226,7 @@ def setValue(self, value):

def value(self):
if self.dialogType == DIALOG_STANDARD:
return self.combo.value()
return self.map_layer_combo.value()
elif self.dialogType == DIALOG_BATCH:
return self.widget.getValue()
else:

0 comments on commit 44ae5a5

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