Skip to content
Browse files

[processing][grass] Make a copy of the parameters dict before doing g…

…rass modifications

Since grass algorithms modify the parameters dictionary, we need to ensure
that they do this only a copy of the dict (and not a shallow copy). Otherwise
the parameter values included in the history log are the internally
modified values, not the original user-set ones

(cherry-picked from fed345b)
  • Loading branch information
nyalldawson committed Jul 24, 2018
1 parent a5519f5 commit 8ad59aa22829d2c1a8211a6eaf028c373ac00b82
Showing with 7 additions and 3 deletions.
  1. +7 −3 python/plugins/processing/algs/grass7/
@@ -363,14 +363,17 @@ def grabDefaultGrassParameters(self, parameters, context):

def processAlgorithm(self, parameters, context, feedback):
def processAlgorithm(self, original_parameters, context, feedback):
if isWindows():
path = Grass7Utils.grassPath()
if path == '':
raise QgsProcessingException('GRASS GIS 7 folder is not configured. Please '
'configure it before running GRASS GIS 7 algorithms.'))

# make a copy of the original parameters dictionary - it gets modified by grass algorithms
parameters = {k: v for k, v in original_parameters.items()}

# Create brand new commands lists
self.commands = []
self.outputCommands = []
@@ -987,8 +990,9 @@ def canExecute(self):
return not message, message

def checkParameterValues(self, parameters, context):
grass_parameters = {k: v for k, v in parameters.items()}
if self.module:
if hasattr(self.module, 'checkParameterValuesBeforeExecuting'):
func = getattr(self.module, 'checkParameterValuesBeforeExecuting')
return func(self, parameters, context)
return super(Grass7Algorithm, self).checkParameterValues(parameters, context)
return func(self, grass_parameters, context)
return super().checkParameterValues(grass_parameters, context)

0 comments on commit 8ad59aa

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