diff --git a/python/plugins/processing/gui/BatchPanel.py b/python/plugins/processing/gui/BatchPanel.py index f8dcd11c1da..081fbce93f5 100644 --- a/python/plugins/processing/gui/BatchPanel.py +++ b/python/plugins/processing/gui/BatchPanel.py @@ -135,6 +135,7 @@ class BatchPanel(BASE, WIDGET): 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 @@ class BatchPanel(BASE, WIDGET): 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 @@ class BatchPanel(BASE, WIDGET): 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 @@ class BatchPanel(BASE, WIDGET): 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()): diff --git a/python/plugins/processing/gui/wrappers.py b/python/plugins/processing/gui/wrappers.py index 7c9f82df6ee..e63b43be3a3 100755 --- a/python/plugins/processing/gui/wrappers.py +++ b/python/plugins/processing/gui/wrappers.py @@ -1286,7 +1286,7 @@ class StringWidgetWrapper(WidgetWrapper): 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: