Skip to content

Commit

Permalink
QGraphicsItem::setGraphicsEffect takes ownership, using a unique_ptr
Browse files Browse the repository at this point in the history
is not appropriate

Refs #54012
  • Loading branch information
nyalldawson committed Oct 3, 2023
1 parent 15f04bb commit ce66298
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/core/layout/qgslayoutitem.cpp
Expand Up @@ -81,7 +81,7 @@ QgsLayoutItem::QgsLayoutItem( QgsLayout *layout, bool manageZValue )
}

// Setup layout effect
mEffect.reset( new QgsLayoutEffect() );
mEffect = new QgsLayoutEffect();
if ( mLayout )
{
mEffect->setEnabled( mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagUseAdvancedEffects );
Expand All @@ -90,7 +90,7 @@ QgsLayoutItem::QgsLayoutItem( QgsLayout *layout, bool manageZValue )
mEffect->setEnabled( flags & QgsLayoutRenderContext::FlagUseAdvancedEffects );
} );
}
setGraphicsEffect( mEffect.get() );
setGraphicsEffect( mEffect.data() );
}

QgsLayoutItem::~QgsLayoutItem()
Expand Down Expand Up @@ -1558,6 +1558,7 @@ void QgsLayoutItem::refreshBlendMode()
}

// Update the item effect to use the new blend mode
mEffect->setCompositionMode( blendMode );
if ( mEffect )
mEffect->setCompositionMode( blendMode );
}

2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutitem.h
Expand Up @@ -1316,7 +1316,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt

//! Composition blend mode for item
QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
std::unique_ptr< QgsLayoutEffect > mEffect;
QPointer< QgsLayoutEffect > mEffect;

//! Item opacity, between 0 and 1
double mOpacity = 1.0;
Expand Down

0 comments on commit ce66298

Please sign in to comment.