Skip to content

Commit ecb6cde

Browse files
committedJan 2, 2019
Pick up all layer entries references from the project context
This is the processing side of the duplicate layer names bug, while the core part was already fixed, the processing logic was extended to handle inputs from models and full-path references. Fixes #20601
1 parent ac6e674 commit ecb6cde

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
 

‎python/plugins/processing/algs/qgis/RasterCalculator.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ def _cellsize(layer):
166166
entry.bandNumber = n + 1
167167
entries.append(entry)
168168

169+
# Append any missing entry from the current project
170+
for entry in QgsRasterCalculatorEntry.rasterEntries():
171+
if not [e for e in entries if e.ref == entry.ref]:
172+
entries.append(entry)
173+
169174
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
170175

171176
width = round((bbox.xMaximum() - bbox.xMinimum()) / cellsize)
@@ -230,8 +235,8 @@ def mappedNameToLayer(self, lyr, expression, layersDict, context):
230235
expContextAlgInputsScope = context.expressionContext().scope(indexOfScope)
231236

232237
# check for the layers that are mapped as input in a model
233-
# to do this check in the latest scope all passed variables
234-
# to look for a variable that is a layer or a string filename ç
238+
# to do this check in the latest scope all passed variables
239+
# to look for a variable that is a layer or a string filename
235240
# to a layer
236241
varDescription = None
237242
for varName in expContextAlgInputsScope.variableNames():
@@ -257,7 +262,7 @@ def mappedNameToLayer(self, lyr, expression, layersDict, context):
257262
# but var in expression is called simply
258263
# 'Output' from algorithm 'calc1'
259264

260-
# get the translatin string to use to parse the description
265+
# get the translation string to use to parse the description
261266
# HAVE to use the same translated string as in
262267
# https://github.com/qgis/QGIS/blob/master/src/core/processing/models/qgsprocessingmodelalgorithm.cpp#L516
263268
translatedDesc = self.tr("Output '%1' from algorithm '%2'")

‎src/analysis/raster/qgsrastercalculator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ QgsRasterCalculator::Result QgsRasterCalculator::processCalculationGPU( std::uni
443443
programTemplate = programTemplate.replace( QStringLiteral( "##EXPRESSION##" ), cExpression );
444444
programTemplate = programTemplate.replace( QStringLiteral( "##EXPRESSION_ORIGINAL##" ), calcNode->toString( ) );
445445

446-
qDebug() << programTemplate;
446+
// qDebug() << programTemplate;
447447

448448
// Create a program from the kernel source
449449
cl::Program program( QgsOpenClUtils::buildProgram( programTemplate, QgsOpenClUtils::ExceptionBehavior::Throw ) );

0 commit comments

Comments
 (0)
Please sign in to comment.