Skip to content
Permalink
Browse files
[processing] Safename for scope variable shouldn't contain "."
Fixes #36377
  • Loading branch information
luipir committed Jun 2, 2020
1 parent cb681e9 commit 08542ef81028cab36d591a2e84829a0ee7757a33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
@@ -826,7 +826,7 @@ QMap<QString, QgsProcessingModelAlgorithm::VariableDefinition> QgsProcessingMode
auto safeName = []( const QString & name )->QString
{
QString s = name;
return s.replace( QRegularExpression( QStringLiteral( "[\\s'\"\\(\\):]" ) ), QStringLiteral( "_" ) );
return s.replace( QRegularExpression( QStringLiteral( "[\\s'\"\\(\\):\\.]" ) ), QStringLiteral( "_" ) );

This comment has been minimized.

Copy link
@luipir

luipir Jun 18, 2021

Author Contributor

probably I've to add \- to the list of characters to change

};

// "static"/single value sources
@@ -9518,6 +9518,20 @@ void TestQgsProcessing::modelExecution()
QGSCOMPARENEAR( variables.value( "SOURCE_LAYER_maxx" ).value.toDouble(), -83.3333, 0.001 );
QGSCOMPARENEAR( variables.value( "SOURCE_LAYER_maxy" ).value.toDouble(), 46.8719, 0.001 );

// test safe name of the child alg parameter as source to another algoritmn
// parameter name should have [\s ' ( ) : .] chars changed to "_" (regexp [\\s'\"\\(\\):\.])
// this case is esecially important in case of grass algs where name algorithm contains "."
// name of the variable is get from childDescription or childId. Refs https://github.com/qgis/QGIS/issues/36377
QgsProcessingModelChildAlgorithm &cx1 = model2.childAlgorithm( "cx1" );
QString oldDescription = cx1.description();
cx1.setDescription( "cx '():.1" );
variables = model2.variablesForChildAlgorithm( "cx3", context );
QVERIFY( !variables.contains( "cx1_OUTPUT" ) );
QVERIFY( !variables.contains( "cx '():.1_OUTPUT" ) );
QVERIFY( variables.contains( "cx______1_OUTPUT" ) );
cx1.setDescription( oldDescription ); // set descrin back to avoid fail of following tests

// test model to python conversion
model2.setName( QStringLiteral( "2my model" ) );
model2.childAlgorithm( "cx1" ).modelOutput( QStringLiteral( "MODEL_OUT_LAYER" ) ).setDescription( "my model output" );
model2.updateDestinationParameters();

0 comments on commit 08542ef

Please sign in to comment.