Skip to content
Permalink
Browse files

qgsprocessingparameters.cpp: add missing nullptr checks (or we should…

… remove all of them)
  • Loading branch information
rouault committed Jun 1, 2020
1 parent 25f89c0 commit 28f5839d0d6a5bec3221c8a8bfff1c7ee678bf3b
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/core/processing/qgsprocessingparameters.cpp
@@ -858,7 +858,7 @@ QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingPara
}

QString dest;
if ( val.canConvert<QgsProperty>() )
if ( definition && val.canConvert<QgsProperty>() )
{
dest = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
}
@@ -888,9 +888,9 @@ QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingPara
outputName = definition->name();

QgsProcessingUtils::LayerHint layerTypeHint = QgsProcessingUtils::LayerHint::UnknownType;
if ( definition->type() == QgsProcessingParameterVectorDestination::typeName() )
if ( definition && definition->type() == QgsProcessingParameterVectorDestination::typeName() )
layerTypeHint = QgsProcessingUtils::LayerHint::Vector;
else if ( definition->type() == QgsProcessingParameterRasterDestination::typeName() )
else if ( definition && definition->type() == QgsProcessingParameterRasterDestination::typeName() )
layerTypeHint = QgsProcessingUtils::LayerHint::Raster;

context.addLayerToLoadOnCompletion( dest, QgsProcessingContext::LayerDetails( destName, destinationProject, outputName, layerTypeHint ) );
@@ -921,11 +921,11 @@ QString QgsProcessingParameters::parameterAsFileOutput( const QgsProcessingParam
}

QString dest;
if ( val.canConvert<QgsProperty>() )
if ( definition && val.canConvert<QgsProperty>() )
{
dest = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
}
else if ( !val.isValid() || val.toString().isEmpty() )
else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
{
// fall back to default
dest = definition->defaultValue().toString();

0 comments on commit 28f5839

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