Skip to content
Permalink
Browse files

[processing] Warn on duplicate output and provider registration

And fix associated memory leaks
  • Loading branch information
nyalldawson committed Feb 1, 2018
1 parent 6fa362b commit 216821c0b15c177920d43d718041d828a0d41a40
@@ -142,8 +142,6 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFolderDestination(self.OUTPUT,
self.tr('Output directory')))

self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, self.tr('Output directory')))

def name(self):
return 'gdal2tiles'

@@ -139,8 +139,6 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFolderDestination(self.OUTPUT,
self.tr('Output directory')))

self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, self.tr('Output directory')))

output_csv_param = QgsProcessingParameterFileDestination(self.OUTPUT_CSV,
self.tr('CSV file containing the tile(s) georeferencing information'),
'CSV files (*.csv)',
@@ -67,8 +67,6 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFolderDestination(self.OUTPUT,
self.tr('Output directory')))

self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, self.tr('Output directory')))

def name(self):
return 'splitvectorlayer'

@@ -86,8 +86,11 @@ def initialize():
# Add the basic providers
for c in QgsProcessingProvider.__subclasses__():
p = c()
Processing.BASIC_PROVIDERS.append(p)
QgsApplication.processingRegistry().addProvider(p)
if p.id() in ('native', '3d'):
# c++ providers are already registered
continue
if QgsApplication.processingRegistry().addProvider(p):
Processing.BASIC_PROVIDERS.append(p)
# And initialize
ProcessingConfig.initialize()
ProcessingConfig.readSettings()
@@ -247,6 +247,7 @@ bool QgsProcessingAlgorithm::addParameter( QgsProcessingParameterDefinition *def
if ( existingDef && existingDef->name() == definition->name() ) // parameterDefinition is case-insensitive, but we DO allow case-different duplicate names
{
QgsMessageLog::logMessage( QObject::tr( "Duplicate parameter %1 registered for alg %2" ).arg( definition->name(), id() ), QObject::tr( "Processing" ) );
delete definition;
return false;
}

@@ -283,7 +284,11 @@ bool QgsProcessingAlgorithm::addOutput( QgsProcessingOutputDefinition *definitio

// check for duplicate named outputs
if ( QgsProcessingAlgorithm::outputDefinition( definition->name() ) )
{
QgsMessageLog::logMessage( QObject::tr( "Duplicate output %1 registered for alg %2" ).arg( definition->name(), id() ), QObject::tr( "Processing" ) );
delete definition;
return false;
}

mOutputs << definition;
return true;
@@ -36,10 +36,18 @@ bool QgsProcessingRegistry::addProvider( QgsProcessingProvider *provider )
return false;

if ( mProviders.contains( provider->id() ) )
{
QgsLogger::warning( QStringLiteral( "Duplicate provider %1 registered" ).arg( provider->id() ) );
delete provider;
return false;
}

if ( !provider->load() )
{
QgsLogger::warning( QStringLiteral( "Provider %1 cannot load" ).arg( provider->id() ) );
delete provider;
return false;
}

provider->setParent( this );
mProviders[ provider->id()] = provider;

0 comments on commit 216821c

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