Skip to content

Commit

Permalink
Ensure correct expression context is used in map select tools,
Browse files Browse the repository at this point in the history
identify tool, map tips and vertex tool

Fixes qgis#42006

(cherry picked from commit 01d9710)
  • Loading branch information
nyalldawson committed May 26, 2021
1 parent 70fa078 commit 0b08524
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/qgsmaptoolselectutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
{
Expand Down
1 change: 1 addition & 0 deletions src/app/vertextool/qgsvertextool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsmaptip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 0b08524

Please sign in to comment.