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

(cherry picked from commit 3c0c253)
  • Loading branch information
nyalldawson committed Jan 17, 2019
1 parent 4d54a1f commit 387334d74767700ede11eed1ba6e9b5833a9fbf2
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/core/symbology/qgssymbollayerutils.cpp
@@ -730,6 +730,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 387334d

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