Skip to content

Commit

Permalink
Fix exception in test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 26, 2020
1 parent 6ac9fca commit 44ae5a5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions python/plugins/processing/gui/wrappers.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 44ae5a5

Please sign in to comment.