@@ -653,7 +653,6 @@ QIcon QgsSymbolLayerUtils::symbolPreviewIcon( QgsSymbol *symbol, QSize size, int
653
653
QPixmap QgsSymbolLayerUtils::symbolPreviewPixmap ( QgsSymbol *symbol, QSize size, int padding, QgsRenderContext *customContext )
654
654
{
655
655
Q_ASSERT ( symbol );
656
-
657
656
QPixmap pixmap ( size );
658
657
pixmap.fill ( Qt::transparent );
659
658
QPainter painter;
@@ -672,7 +671,25 @@ QPixmap QgsSymbolLayerUtils::symbolPreviewPixmap( QgsSymbol *symbol, QSize size,
672
671
painter.translate ( padding, padding );
673
672
}
674
673
675
- symbol->drawPreviewIcon ( &painter, size, customContext );
674
+ // If the context has no feature and there are DD properties,
675
+ // use a clone and clear all DDs: see issue #19096
676
+ // Applying a data defined size to a categorized layer hides its category symbol in the layers panel and legend
677
+ if ( symbol->hasDataDefinedProperties () &&
678
+ !( customContext
679
+ && customContext->expressionContext ().hasFeature ( ) ) )
680
+ {
681
+ std::unique_ptr<QgsSymbol> symbol_noDD ( symbol->clone ( ) );
682
+ const QgsSymbolLayerList layers ( symbol_noDD->symbolLayers () );
683
+ for ( const auto &layer : layers )
684
+ {
685
+ layer->dataDefinedProperties ().clear ();
686
+ }
687
+ symbol_noDD->drawPreviewIcon ( &painter, size, customContext );
688
+ }
689
+ else
690
+ {
691
+ symbol->drawPreviewIcon ( &painter, size, customContext );
692
+ }
676
693
677
694
painter.end ();
678
695
return pixmap;
0 commit comments