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

(cherry picked from commit 3c0c253)
  • Loading branch information
nyalldawson committed Jan 17, 2019
1 parent 4d54a1f commit 387334d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 387334d

Please sign in to comment.