From b86bb1e2efbba39ed0c025d1bcc34a1bb28abb1b Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 22 Jun 2023 15:36:22 +1000 Subject: [PATCH] Simplify logic --- src/core/layertree/qgslayertreemodellegendnode.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core/layertree/qgslayertreemodellegendnode.cpp b/src/core/layertree/qgslayertreemodellegendnode.cpp index 873beab3b02..b4c81b70d58 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.cpp +++ b/src/core/layertree/qgslayertreemodellegendnode.cpp @@ -548,7 +548,6 @@ QVariant QgsSymbolLegendNode::data( int role ) const { if ( mPixmap.isNull() ) { - QPixmap pix; if ( mItem.symbol() ) { std::unique_ptr context( createTemporaryRenderContext() ); @@ -557,11 +556,11 @@ QVariant QgsSymbolLegendNode::data( int role ) const double width = 0.0; double height = 0.0; const std::unique_ptr symbol( QgsSymbolLayerUtils::restrictedSizeSymbol( mItem.symbol(), MINIMUM_SIZE, MAXIMUM_SIZE, context.get(), width, height ) ); - pix = QgsSymbolLayerUtils::symbolPreviewPixmap( symbol ? symbol.get() : mItem.symbol(), mIconSize, 0, context.get() ); + mPixmap = QgsSymbolLayerUtils::symbolPreviewPixmap( symbol ? symbol.get() : mItem.symbol(), mIconSize, 0, context.get() ); if ( !mTextOnSymbolLabel.isEmpty() && context ) { - QPainter painter( &pix ); + QPainter painter( &mPixmap ); painter.setRenderHint( QPainter::Antialiasing ); context->setPainter( &painter ); bool isNullSize = false; @@ -576,11 +575,9 @@ QVariant QgsSymbolLegendNode::data( int role ) const } else { - pix = QPixmap( mIconSize ); - pix.fill( Qt::transparent ); + mPixmap = QPixmap( mIconSize ); + mPixmap.fill( Qt::transparent ); } - - mPixmap = pix; } return mPixmap; }