Skip to content
Permalink
Browse files

[processing] Fix some exceptions in batch dialog after refactoring

Fixes #19779, #19786
  • Loading branch information
nyalldawson committed Sep 8, 2018
1 parent 32ee716 commit 1c5250b147edc1b4ad845884c0f4249ec5a99b43
Showing with 20 additions and 5 deletions.
  1. +19 −4 python/plugins/processing/gui/BatchPanel.py
  2. +1 −1 python/plugins/processing/gui/wrappers.py
@@ -135,6 +135,7 @@ def initWidgets(self):
self.tblParameters.horizontalHeader().setStretchLastSection(True)

def load(self):
context = dataobjects.createContext()
settings = QgsSettings()
last_path = settings.value("/Processing/LastBatchPath", QDir.homePath())
filename, selected_filter = QFileDialog.getOpenFileName(self,
@@ -164,7 +165,7 @@ def load(self):
if param.name() in params:
value = eval(params[param.name()])
wrapper = self.wrappers[row][column]
wrapper.setValue(value)
wrapper.setParameterValue(value, context)
column += 1

for out in self.alg.destinationParameterDefinitions():
@@ -195,12 +196,24 @@ def save(self):
if param.isDestination():
continue
wrapper = self.wrappers[row][col]
if not param.checkValueIsAcceptable(wrapper.value(), context):

# For compatibility with 3.x API, we need to check whether the wrapper is
# the deprecated WidgetWrapper class. If not, it's the newer
# QgsAbstractProcessingParameterWidgetWrapper class
# TODO QGIS 4.0 - remove
if issubclass(wrapper.__class__, WidgetWrapper):
widget = wrapper.widget
else:
widget = wrapper.wrappedWidget()

value = wrapper.parameterValue()

if not param.checkValueIsAcceptable(value, context):
self.parent.messageBar().pushMessage("", self.tr('Wrong or missing parameter value: {0} (row {1})').format(
param.description(), row + 1),
level=Qgis.Warning, duration=5)
return
algParams[param.name()] = param.valueAsPythonString(wrapper.value(), context)
algParams[param.name()] = param.valueAsPythonString(value, context)
col += 1
for out in alg.destinationParameterDefinitions():
if out.flags() & QgsProcessingParameterDefinition.FlagHidden:
@@ -289,13 +302,15 @@ def removeRows(self):
self.tblParameters.setRowCount(self.tblParameters.rowCount() - 1)

def fillParameterValues(self, column):
context = dataobjects.createContext()

wrapper = self.wrappers[0][column]
if wrapper is None:
# e.g. double clicking on a destination header
return

for row in range(1, self.tblParameters.rowCount()):
self.wrappers[row][column].setValue(wrapper.value())
self.wrappers[row][column].setParameterValue(wrapper.value(), context)

def toggleAdvancedMode(self, checked):
for column, param in enumerate(self.alg.parameterDefinitions()):
@@ -1286,7 +1286,7 @@ def setValue(self, value):
self.setComboValue(value)

def value(self):
if self.dialogType in DIALOG_STANDARD:
if self.dialogType == DIALOG_STANDARD:
if self.parameterDefinition().multiLine():
text = self.widget.toPlainText()
else:

0 comments on commit 1c5250b

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