mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
fix crash when a sink parameter definition is missing in a processing alg (#34978)
This commit is contained in:
parent
35d8b062ca
commit
14b80de7ed
@ -623,7 +623,7 @@ Evaluates the parameter with matching ``name`` to a static boolean value.
|
||||
%End
|
||||
|
||||
QgsFeatureSink *parameterAsSink( const QVariantMap ¶meters, 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.
|
||||
|
||||
@ -637,6 +637,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 ¶meters, const QString &name, QgsProcessingContext &context ) const /Factory/;
|
||||
|
@ -754,7 +754,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.
|
||||
|
||||
@ -768,6 +768,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 @@ while ($LINE_IDX < $LINE_COUNT){
|
||||
# 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 ¶meters,
|
||||
|
||||
QgsFeatureSink *QgsProcessingAlgorithm::parameterAsSink( const QVariantMap ¶meters, 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 ¶meters, const QString &name, QgsProcessingContext &context ) const
|
||||
|
@ -628,9 +628,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 ¶meters, 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.
|
||||
|
@ -548,6 +548,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
|
||||
|
@ -821,12 +821,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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user