Skip to content
Permalink
Browse files

Use a minimal expression context in symbol layer tree preview icons

Allows the preview icon to correctly show linked project colors
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent 9419bfd commit 3c0c2535d63b8a143671433deff6cbf9fdad23dc
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/core/symbology/qgssymbollayerutils.cpp
@@ -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();

0 comments on commit 3c0c253

Please sign in to comment.
You can’t perform that action at this time.