Memory leak?

Boudewijn Rempt boud at valdyas.org
Wed Oct 12 14:10:57 CEST 2005


On Wednesday 12 October 2005 14:07, Michael Thaler wrote:
> Hello,
>
> I think I introduced a memory leak in the dropshadow plugin. I do the
> following:
>
> KisLayerSP shadowLayer = new
> KisLayer( KisColorSpaceFactoryRegistry::instance() ->
> getColorSpace(KisID("RGBA",""),"" ), "Shadow");
>     KisLayerSP bShadowLayer;
> ...
> if( blurshadow )
>     {
>         bShadowLayer = new KisLayer(
> KisColorSpaceFactoryRegistry::instance() ->
> getColorSpace(KisID("RGBA",""),"" ), "bShadow");
>         gaussianblur(shadowLayer, bShadowLayer, rect, blurradius,
> blurradius, BLUR_RLE, progress);
>         shadowLayer = bShadowLayer;
>     }
>
> I think I should do something like
>
> delete  shadowLayer
>
> before I do
>
>  shadowLayer = bShadowLayer
>
> But that crashed Krita. Basically shadowLayer is the original shadowLayer
> and bShadowLayer holds the blurred version of the shadow. So after I
> blurred the shadow, I want shadowLayer to point to the blurred version. How
> should I delete the original ShadowLayer?

You don't need to: it's a smart pointer, so everything will be cleaned up 
correctly when both variables go out of scope.

-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi


More information about the kimageshop mailing list