diff --git a/python/PyQt6/core/auto_generated/processing/qgsprocessingalgorithm.sip.in b/python/PyQt6/core/auto_generated/processing/qgsprocessingalgorithm.sip.in index 28c54aac178e..8f91679714fc 100644 --- a/python/PyQt6/core/auto_generated/processing/qgsprocessingalgorithm.sip.in +++ b/python/PyQt6/core/auto_generated/processing/qgsprocessingalgorithm.sip.in @@ -542,6 +542,7 @@ See the notes in :py:func:`~QgsProcessingAlgorithm.addParameter` for a descripti .. seealso:: :py:func:`initAlgorithm` %End + virtual bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) /VirtualErrorHandler=processing_exception_handler/; %Docstring Prepares the algorithm to run using the specified ``parameters``. Algorithms should implement diff --git a/python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in b/python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in index 6d4192efc27f..fa137479bda6 100644 --- a/python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in +++ b/python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in @@ -542,6 +542,7 @@ See the notes in :py:func:`~QgsProcessingAlgorithm.addParameter` for a descripti .. seealso:: :py:func:`initAlgorithm` %End + virtual bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) /VirtualErrorHandler=processing_exception_handler/; %Docstring Prepares the algorithm to run using the specified ``parameters``. Algorithms should implement diff --git a/src/core/processing/qgsprocessingalgorithm.cpp b/src/core/processing/qgsprocessingalgorithm.cpp index bec0499c6c3c..4f2808525b7f 100644 --- a/src/core/processing/qgsprocessingalgorithm.cpp +++ b/src/core/processing/qgsprocessingalgorithm.cpp @@ -444,6 +444,11 @@ void QgsProcessingAlgorithm::removeParameter( const QString &name ) } bool QgsProcessingAlgorithm::addOutput( QgsProcessingOutputDefinition *definition ) +{ + return addOutput( std::unique_ptr( definition ) ); +} + +bool QgsProcessingAlgorithm::addOutput( std::unique_ptr definition ) { if ( !definition ) return false; @@ -452,11 +457,10 @@ bool QgsProcessingAlgorithm::addOutput( QgsProcessingOutputDefinition *definitio 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; + mOutputs << definition.release(); return true; } diff --git a/src/core/processing/qgsprocessingalgorithm.h b/src/core/processing/qgsprocessingalgorithm.h index 5af4989a706f..d502da7f6380 100644 --- a/src/core/processing/qgsprocessingalgorithm.h +++ b/src/core/processing/qgsprocessingalgorithm.h @@ -554,6 +554,12 @@ class CORE_EXPORT QgsProcessingAlgorithm */ bool addOutput( QgsProcessingOutputDefinition *outputDefinition SIP_TRANSFER ) SIP_HOLDGIL; + /** + * Same as above addOutput(QgsProcessingOutputDefinition*), but using + * a smart pointer for safer use. + */ + bool addOutput( std::unique_ptr outputDefinition ) SIP_SKIP; + /** * Prepares the algorithm to run using the specified \a parameters. Algorithms should implement * their logic for evaluating parameter values here. The evaluated parameter results should