Skip to content

Commit

Permalink
[bugfix] Clear all DD props before creating symbol preview
Browse files Browse the repository at this point in the history
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 9fc87aa
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 9fc87aa

Please sign in to comment.