Skip to content

Commit

Permalink
Fix layer expression scope sometimes not appended to render
Browse files Browse the repository at this point in the history
context expression scopes
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent 17d4d3a commit 2c24175
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/qgslabelingengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down
1 change: 1 addition & 0 deletions src/core/qgsmaprendererjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgsdiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit 2c24175

Please sign in to comment.