Skip to content
Permalink
Browse files

[bugfix] Clear all DD props before creating symbol preview

Fixes #19096 - Applying a data defined size to a categorized layer hides its category symbol in the layers panel and legend
  • Loading branch information
elpaso committed Jun 11, 2018
1 parent 4e084b6 commit 9fc87aab7f42cad3cda7724d66f5aec9df4b8639
Showing with 19 additions and 2 deletions.
  1. +19 −2 src/core/symbology/qgssymbollayerutils.cpp
@@ -653,7 +653,6 @@ QIcon QgsSymbolLayerUtils::symbolPreviewIcon( QgsSymbol *symbol, QSize size, int
QPixmap QgsSymbolLayerUtils::symbolPreviewPixmap( QgsSymbol *symbol, QSize size, int padding, QgsRenderContext *customContext )
{
Q_ASSERT( symbol );

QPixmap pixmap( size );
pixmap.fill( Qt::transparent );
QPainter painter;
@@ -672,7 +671,25 @@ QPixmap QgsSymbolLayerUtils::symbolPreviewPixmap( QgsSymbol *symbol, QSize size,
painter.translate( padding, padding );
}

symbol->drawPreviewIcon( &painter, size, customContext );
// If the context has no feature and there are DD properties,
// use a clone and clear all DDs: see issue #19096
// Applying a data defined size to a categorized layer hides its category symbol in the layers panel and legend
if ( symbol->hasDataDefinedProperties() &&
!( customContext
&& customContext->expressionContext().hasFeature( ) ) )
{
std::unique_ptr<QgsSymbol> symbol_noDD( symbol->clone( ) );
const QgsSymbolLayerList layers( symbol_noDD->symbolLayers() );
for ( const auto &layer : layers )
{
layer->dataDefinedProperties().clear();
}
symbol_noDD->drawPreviewIcon( &painter, size, customContext );
}
else
{
symbol->drawPreviewIcon( &painter, size, customContext );
}

painter.end();
return pixmap;

0 comments on commit 9fc87aa

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