Skip to content
Permalink
Browse files

Fix conversion of direct vector layer parameters to python strings

  • Loading branch information
nyalldawson committed Aug 20, 2017
1 parent f867b65 commit d2a90f40e34e2b93aac0fbaec64c6353d22dad73
Showing with 5 additions and 0 deletions.
  1. +4 −0 src/core/processing/qgsprocessingparameters.cpp
  2. +1 −0 tests/src/core/testqgsprocessing.cpp
@@ -2565,6 +2565,10 @@ QString QgsProcessingParameterFeatureSource::valueAsPythonString( const QVariant
}
}
}
else if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
{
return layer->source().prepend( '\'' ).append( '\'' );
}

return value.toString().prepend( '\'' ).append( '\'' );
}
@@ -3442,6 +3442,7 @@ void TestQgsProcessing::parameterFeatureSource()
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingFeatureSourceDefinition( QgsProperty::fromValue( "abc" ), true ) ), context ), QStringLiteral( "QgsProcessingFeatureSourceDefinition('abc', True)" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingFeatureSourceDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"abc\" || \"def\"')" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( v2 ), context ), QStringLiteral( "'%1'" ).arg( vector2 ) );

QVariantMap map = def->toVariantMap();
QgsProcessingParameterFeatureSource fromMap( "x" );

0 comments on commit d2a90f4

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