mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
[processing] A non-optional multiple enum parameter must have at
least one choice selected to be valid
This commit is contained in:
parent
4bae647ad9
commit
dd441f6154
@ -1988,7 +1988,11 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &input,
|
||||
if ( !mAllowMultiple )
|
||||
return false;
|
||||
|
||||
Q_FOREACH ( const QVariant &val, input.toList() )
|
||||
const QVariantList values = input.toList();
|
||||
if ( values.empty() && !( mFlags & FlagOptional ) )
|
||||
return false;
|
||||
|
||||
for ( const QVariant &val : values )
|
||||
{
|
||||
bool ok = false;
|
||||
int res = val.toInt( &ok );
|
||||
|
@ -2784,6 +2784,7 @@ void TestQgsProcessing::parameterEnum()
|
||||
QVERIFY( def->checkValueIsAcceptable( "1" ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( "1,2" ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( 0 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() << 1 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() << "a" ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( 15 ) );
|
||||
@ -2853,6 +2854,7 @@ void TestQgsProcessing::parameterEnum()
|
||||
QVERIFY( def->checkValueIsAcceptable( "1" ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( "1,2" ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( 0 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() ) ); // since non-optional, empty list not allowed
|
||||
QVERIFY( def->checkValueIsAcceptable( QVariantList() << 1 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() << "a" ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( 15 ) );
|
||||
@ -2893,6 +2895,7 @@ void TestQgsProcessing::parameterEnum()
|
||||
QVERIFY( def->checkValueIsAcceptable( "1" ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( "1,2" ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( 0 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() << 1 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() << "a" ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( 15 ) );
|
||||
@ -2925,6 +2928,7 @@ void TestQgsProcessing::parameterEnum()
|
||||
QVERIFY( def->checkValueIsAcceptable( "1" ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( "1,2" ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( 0 ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( QVariantList() ) );
|
||||
QVERIFY( def->checkValueIsAcceptable( QVariantList() << 1 ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( QVariantList() << "a" ) );
|
||||
QVERIFY( !def->checkValueIsAcceptable( 15 ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user