Skip to content
Permalink
Browse files

Fix default layer sometimes inserted into multi layer parameter values

  • Loading branch information
nyalldawson committed Aug 16, 2017
1 parent 48eccc3 commit e1b0f7861922e4709566f62adc8a7c9b916cec51
Showing with 4 additions and 1 deletion.
  1. +1 −1 src/core/processing/qgsprocessingparameters.cpp
  2. +3 −0 tests/src/core/testqgsprocessing.cpp
@@ -622,7 +622,7 @@ QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsPro
else
resultStringList << val.toString();

if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
if ( layers.isEmpty() && ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
{
resultStringList.clear();
// check default
@@ -2310,6 +2310,9 @@ void TestQgsProcessing::parameterLayerList()
params.insert( "optional", QVariant() );
QCOMPARE( QgsProcessingParameters::parameterAsLayerList( def.get(), params, context ), QList< QgsMapLayer *>() << v1 );

params.insert( "optional", QVariantList() << QVariant::fromValue( r1 ) );
QCOMPARE( QgsProcessingParameters::parameterAsLayerList( def.get(), params, context ), QList< QgsMapLayer *>() << r1 );

code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##optional=optional multiple vector " ) + v1->id() );
fromCode.reset( dynamic_cast< QgsProcessingParameterMultipleLayers * >( QgsProcessingParameters::parameterFromScriptCode( code ) ) );

0 comments on commit e1b0f78

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