Skip to content
Permalink
Browse files
Fix layer expression scope sometimes not appended to render
context expression scopes
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent 17d4d3a commit 2c241755f8b23767c7e0f3399b9d2b6bb0c31e46
Showing with 10 additions and 0 deletions.
  1. +8 −0 src/core/qgslabelingengine.cpp
  2. +1 −0 src/core/qgsmaprendererjob.cpp
  3. +1 −0 tests/src/core/testqgsdiagram.cpp
@@ -213,7 +213,15 @@ void QgsLabelingEngine::run( QgsRenderContext& context )
// for each provider: get labels and register them in PAL
Q_FOREACH ( QgsAbstractLabelProvider* provider, mProviders )
{
bool appendedLayerScope = false;
if ( QgsMapLayer* ml = QgsProject::instance()->mapLayer( provider->layerId() ) )
{
appendedLayerScope = true;
context.expressionContext().appendScope( QgsExpressionContextUtils::layerScope( ml ) );
}
processProvider( provider, context, p ); //#spellok
if ( appendedLayerScope )
delete context.expressionContext().popScope();
}


@@ -245,6 +245,7 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsLabelingEn
job.renderingTime = -1;

job.context = QgsRenderContext::fromMapSettings( mSettings );
job.context.expressionContext().appendScope( QgsExpressionContextUtils::layerScope( ml ) );
job.context.setPainter( painter );
job.context.setLabelingEngine( labelingEngine2 );
job.context.setCoordinateTransform( ct );
@@ -98,6 +98,7 @@ class TestQgsDiagram : public QObject
mPointsLayer->setRenderer( symbolRenderer );

// Create map composition to draw on
QgsProject::instance()->addMapLayer( mPointsLayer );
mMapSettings->setLayers( QList<QgsMapLayer*>() << mPointsLayer );

mReport += QLatin1String( "<h1>Diagram Tests</h1>\n" );

0 comments on commit 2c24175

Please sign in to comment.