Skip to content

Commit

Permalink
fix crash when QgsFeature has no layer
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed Jul 7, 2020
1 parent a9d943d commit 86deebd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -5696,7 +5696,7 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
request.setFilterExpression( filterString ); //filter cached features
}

if ( targetLayer->crs() != sourceLayer->crs() )
if ( sourceLayer && targetLayer->crs() != sourceLayer->crs() )
{
QgsCoordinateTransformContext TransformContext = context->variable( QStringLiteral( "_project_transform_context" ) ).value<QgsCoordinateTransformContext>();
request.setDestinationCrs( sourceLayer->crs(), TransformContext ); //if crs are not the same, cached target will be reprojected to source crs
Expand Down Expand Up @@ -5763,7 +5763,7 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
const QgsGeometry geometry = feat.geometry();

QVariant currentFeatId;
if ( sourceLayer->id() == targetLayerValue )
if ( sourceLayer && sourceLayer->id() == targetLayerValue )
{
currentFeatId = feat.id(); //if sourceLayer and targetLayer are the same, current feature have to be excluded from spatial check
}
Expand Down

0 comments on commit 86deebd

Please sign in to comment.