Skip to content

Commit 3c0c253

Browse files
committedJan 16, 2019
Use a minimal expression context in symbol layer tree preview icons
Allows the preview icon to correctly show linked project colors
1 parent 9419bfd commit 3c0c253

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎src/core/symbology/qgssymbollayerutils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,11 @@ QIcon QgsSymbolLayerUtils::symbolLayerPreviewIcon( QgsSymbolLayer *layer, QgsUni
736736
painter.begin( &pixmap );
737737
painter.setRenderHint( QPainter::Antialiasing );
738738
QgsRenderContext renderContext = QgsRenderContext::fromQPainter( &painter );
739+
// build a minimal expression context
740+
QgsExpressionContext expContext;
741+
expContext.appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( nullptr ) );
742+
renderContext.setExpressionContext( expContext );
743+
739744
QgsSymbolRenderContext symbolContext( renderContext, u, 1.0, false, nullptr, nullptr, QgsFields(), scale );
740745
layer->drawPreviewIcon( symbolContext, size );
741746
painter.end();

0 commit comments

Comments
 (0)