Skip to content

Commit

Permalink
Use a minimal expression context in symbol layer tree preview icons
Browse files Browse the repository at this point in the history
Allows the preview icon to correctly show linked project colors
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent 9419bfd commit 3c0c253
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/symbology/qgssymbollayerutils.cpp
Expand Up @@ -736,6 +736,11 @@ QIcon QgsSymbolLayerUtils::symbolLayerPreviewIcon( QgsSymbolLayer *layer, QgsUni
painter.begin( &pixmap );
painter.setRenderHint( QPainter::Antialiasing );
QgsRenderContext renderContext = QgsRenderContext::fromQPainter( &painter );
// build a minimal expression context
QgsExpressionContext expContext;
expContext.appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( nullptr ) );
renderContext.setExpressionContext( expContext );

QgsSymbolRenderContext symbolContext( renderContext, u, 1.0, false, nullptr, nullptr, QgsFields(), scale );
layer->drawPreviewIcon( symbolContext, size );
painter.end();
Expand Down

0 comments on commit 3c0c253

Please sign in to comment.