Skip to content
Permalink
Browse files

fix crash when a sink parameter definition is missing in a processing…

… alg (#35073)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
qgis-bot and github-actions committed Mar 14, 2020
1 parent f039403 commit 1b0c72489172287c722a4b410334fbb98dd220c1
@@ -622,7 +622,7 @@ Evaluates the parameter with matching ``name`` to a static boolean value.
%End

QgsFeatureSink *parameterAsSink( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier /Out/,
const QgsFields &fields, QgsWkbTypes::Type geometryType = QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags = 0 ) const /Factory/;
const QgsFields &fields, QgsWkbTypes::Type geometryType = QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags = 0 ) const throw( QgsProcessingException ) /Factory/;
%Docstring
Evaluates the parameter with matching ``name`` to a feature sink.

@@ -636,6 +636,8 @@ The ``destinationIdentifier`` argument will be set to a string which can be used
to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`

This function creates a new object and the caller takes responsibility for deleting the returned object.

:raises :: py:class:`QgsProcessingException`
%End

QgsProcessingFeatureSource *parameterAsSource( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const /Factory/;
@@ -684,7 +684,7 @@ This function creates a new object and the caller takes responsibility for delet

static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
QgsProcessingContext &context, QString &destinationIdentifier /Out/, QgsFeatureSink::SinkFlags sinkFlags = 0 ) /Factory/;
QgsProcessingContext &context, QString &destinationIdentifier /Out/, QgsFeatureSink::SinkFlags sinkFlags = 0 ) throw( QgsProcessingException ) /Factory/;
%Docstring
Evaluates the parameter with matching ``definition`` and ``value`` to a feature sink.

@@ -698,6 +698,8 @@ to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`

This function creates a new object and the caller takes responsibility for deleting the returned object.

:raises :: py:class:`QgsProcessingException`

.. versionadded:: 3.4
%End

@@ -1210,8 +1210,8 @@ sub detect_non_method_member{
# multiline definition (parenthesis left open)
if ( $MULTILINE_DEFINITION != MULTILINE_NO ){
dbg_info("on multiline");
# https://regex101.com/r/DN01iM/2
if ( $LINE =~ m/^([^()]+(\((?:[^()]++|(?1))*\)))*[^()]*\)[^()]*$/){
# https://regex101.com/r/DN01iM/4
if ( $LINE =~ m/^([^()]+(\((?:[^()]++|(?1))*\)))*[^()]*\)([^()](throw\([^()]+\))?)*$/){
dbg_info("ending multiline");
# remove potential following body
if ( $MULTILINE_DEFINITION != MULTILINE_CONDITIONAL_STATEMENT && $LINE !~ m/(\{.*\}|;)\s*(\/\/.*)?$/ ){
@@ -599,7 +599,14 @@ bool QgsProcessingAlgorithm::parameterAsBoolean( const QVariantMap &parameters,

QgsFeatureSink *QgsProcessingAlgorithm::parameterAsSink( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsFeatureSink::SinkFlags sinkFlags ) const
{
return QgsProcessingParameters::parameterAsSink( parameterDefinition( name ), parameters, fields, geometryType, crs, context, destinationIdentifier, sinkFlags );
try
{
return QgsProcessingParameters::parameterAsSink( parameterDefinition( name ), parameters, fields, geometryType, crs, context, destinationIdentifier, sinkFlags );
}
catch ( QgsProcessingException )
{
throw QgsProcessingException( QObject::tr( "No parameter definition for the sink '%1'" ).arg( name ) );
}
}

QgsProcessingFeatureSource *QgsProcessingAlgorithm::parameterAsSource( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
@@ -627,9 +627,11 @@ class CORE_EXPORT QgsProcessingAlgorithm
* to the sink, e.g. via calling QgsProcessingUtils::mapLayerFromString().
*
* This function creates a new object and the caller takes responsibility for deleting the returned object.
*
* \throws QgsProcessingException
*/
QgsFeatureSink *parameterAsSink( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT,
const QgsFields &fields, QgsWkbTypes::Type geometryType = QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags = nullptr ) const SIP_FACTORY;
const QgsFields &fields, QgsWkbTypes::Type geometryType = QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags = nullptr ) const SIP_THROW( QgsProcessingException ) SIP_FACTORY;

/**
* Evaluates the parameter with matching \a name to a feature source.
@@ -431,6 +431,10 @@ QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingPar
return nullptr;
}
// fall back to default
if ( !definition )
{
throw QgsProcessingException( QObject::tr( "No parameter definition for the sink" ) );
}
dest = definition->defaultValue().toString();
}
else
@@ -757,12 +757,12 @@ class CORE_EXPORT QgsProcessingParameters
* to the sink, e.g. via calling QgsProcessingUtils::mapLayerFromString().
*
* This function creates a new object and the caller takes responsibility for deleting the returned object.
*
* \throws QgsProcessingException
* \since QGIS 3.4
*/
static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = nullptr ) SIP_FACTORY;
QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = nullptr ) SIP_THROW( QgsProcessingException ) SIP_FACTORY;

/**
* Evaluates the parameter with matching \a definition to a feature source.

0 comments on commit 1b0c724

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