Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Fix duplicate parameter
And throw warnings when other duplicate parameters are registered.

GRASS has a lot.
  • Loading branch information
nyalldawson committed Jan 28, 2018
1 parent 7e20fe4 commit 285bb06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/analysis/processing/qgsalgorithmuniquevalueindex.cpp
Expand Up @@ -62,8 +62,6 @@ void QgsAddUniqueValueIndexAlgorithm::initAlgorithm( const QVariantMap & )
classedOutput->setCreateByDefault( true );
addParameter( classedOutput.release() );

addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Layer with index field" ), QgsProcessing::TypeVector, QVariant(), true ) );

std::unique_ptr< QgsProcessingParameterFeatureSink > summaryOutput = qgis::make_unique< QgsProcessingParameterFeatureSink >( QStringLiteral( "SUMMARY_OUTPUT" ), QObject::tr( "Class summary" ),
QgsProcessing::TypeVector, QVariant(), true );
summaryOutput->setCreateByDefault( false );
Expand Down
3 changes: 3 additions & 0 deletions src/core/processing/qgsprocessingalgorithm.cpp
Expand Up @@ -244,7 +244,10 @@ bool QgsProcessingAlgorithm::addParameter( QgsProcessingParameterDefinition *def

// check for duplicate named parameters
if ( QgsProcessingAlgorithm::parameterDefinition( definition->name() ) )
{
QgsLogger::warning( QStringLiteral( "Duplicate parameter %1 registered for alg %2" ).arg( definition->name(), id() ) );
return false;
}

if ( definition->isDestination() && mProvider )
{
Expand Down
3 changes: 3 additions & 0 deletions src/core/processing/qgsprocessingprovider.cpp
Expand Up @@ -75,7 +75,10 @@ bool QgsProcessingProvider::addAlgorithm( QgsProcessingAlgorithm *algorithm )
return false;

if ( mAlgorithms.contains( algorithm->name() ) )
{
QgsLogger::warning( QStringLiteral( "Duplicate algorithm name %1 for provider %2" ).arg( algorithm->name(), id() ) );
return false;
}

// init the algorithm - this allows direct querying of the algorithm's parameters
// and outputs from the provider's copy
Expand Down

0 comments on commit 285bb06

Please sign in to comment.