Skip to content
Permalink
Browse files

Fix duplicate parameter warnings shown when loading models

  • Loading branch information
github-actions authored and nyalldawson committed Nov 9, 2020
1 parent fcafb27 commit 06bfb4251b1412f3305bbbf0b9e582bf499c6d20
@@ -1348,6 +1348,9 @@ QVariant QgsProcessingModelAlgorithm::toVariant() const
QVariantMap paramDefMap;
for ( const QgsProcessingParameterDefinition *def : mParameters )
{
if ( def->name() == QStringLiteral( "VERBOSE_LOG" ) )
continue;

paramDefMap.insert( def->name(), def->toVariantMap() );
}
map.insert( QStringLiteral( "parameterDefinitions" ), paramDefMap );
@@ -1420,7 +1423,12 @@ bool QgsProcessingModelAlgorithm::loadVariant( const QVariant &model )
// otherwise models may become unusable (e.g. due to removed plugins providing algs/parameters)
// with no way for users to repair them
if ( param )
{
if ( param->name() == QLatin1String( "VERBOSE_LOG" ) )
return; // internal parameter -- some versions of QGIS incorrectly stored this in the model definition file

addParameter( param.release() );
}
else
{
QVariantMap map = value.toMap();
alg5.setDesignerParameterValues( lastParams );

QDomDocument doc = QDomDocument( "model" );
QDomElement elem = QgsXmlUtils::writeVariant( alg5.toVariant(), doc );
alg5.initAlgorithm();
const QVariant v = alg5.toVariant();
// make sure private parameters weren't included in the definition
QVERIFY( !v.toMap().value( QStringLiteral( "parameterDefinitions" ) ).toMap().contains( QStringLiteral( "VERBOSE_LOG" ) ) );

QDomElement elem = QgsXmlUtils::writeVariant( v, doc );
doc.appendChild( elem );

QgsProcessingModelAlgorithm alg6;

0 comments on commit 06bfb42

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