Skip to content

Commit

Permalink
qgsprocessingparameters.cpp: add missing nullptr checks (or we should…
Browse files Browse the repository at this point in the history
… remove all of them)
  • Loading branch information
rouault committed Jun 1, 2020
1 parent 25f89c0 commit 28f5839
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/processing/qgsprocessingparameters.cpp
Expand Up @@ -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() );
}
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 28f5839

Please sign in to comment.