Use a minimal expression context in symbol layer tree preview icons

Allows the preview icon to correctly show linked project colors
This commit is contained in:
Nyall Dawson 2019-01-17 07:19:50 +10:00
parent 9419bfdc5f
commit 3c0c2535d6

View File

@ -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();