Skip to content
Permalink
Browse files
Ensure correct expression context is used in map select tools,
identify tool, map tips and vertex tool

Fixes #42006

(cherry picked from commit 01d9710)
  • Loading branch information
nyalldawson committed May 31, 2021
1 parent 2f62585 commit 8f02e694dd8c8a97a924d33ccb74b623af81a88a
@@ -245,7 +245,11 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas,
selectionGeometryEngine->prepareGeometry();

QgsRenderContext context = QgsRenderContext::fromMapSettings( canvas->mapSettings() );
context.expressionContext() << QgsExpressionContextUtils::layerScope( vlayer );

QgsExpressionContext expressionContext = canvas->createExpressionContext();
expressionContext << QgsExpressionContextUtils::layerScope( vlayer );
context.setExpressionContext( expressionContext );

std::unique_ptr< QgsFeatureRenderer > r;
if ( vlayer->renderer() )
{
@@ -564,6 +564,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}

QgsRenderContext context = QgsRenderContext::fromMapSettings( mCanvas->mapSettings() );
context.setExpressionContext( mCanvas->createExpressionContext() );
context.expressionContext() << QgsExpressionContextUtils::layerScope( vlayer );
std::unique_ptr< QgsFeatureRenderer > r;
if ( vlayer->renderer() )
@@ -239,6 +239,7 @@ QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPointXY &mapPosition, Qg
}

QgsRenderContext renderCtx = QgsRenderContext::fromMapSettings( mapCanvas->mapSettings() );
renderCtx.setExpressionContext( mapCanvas->createExpressionContext() );
renderCtx.expressionContext() << QgsExpressionContextUtils::layerScope( vlayer );

bool filter = false;
@@ -607,6 +607,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
bool filter = false;

QgsRenderContext context( QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ) );
context.setExpressionContext( mCanvas->createExpressionContext() );
context.expressionContext() << QgsExpressionContextUtils::layerScope( layer );
std::unique_ptr< QgsFeatureRenderer > renderer( layer->renderer() ? layer->renderer()->clone() : nullptr );
if ( renderer )

0 comments on commit 8f02e69

Please sign in to comment.