[vlc-devel] [PATCH] gui/qt: pictureflow: clear cache on destruction

Filip Roséen filip at atch.se
Wed Mar 1 10:32:31 CET 2017


Hi Hugo,

On 2017-03-01 09:57, Hugo Beauzée-Luyssen wrote:

> On Wed, Mar 1, 2017, at 09:52 AM, Filip Roséen wrote:
> > PictureFlowRenderer::cache is used to store QImage's for later use,
> > though given that no clean-up was previously implemented we would leak
> > all QImage's inside the container.
> > 
> > diff --git a/modules/gui/qt/util/pictureflow.cpp
> > b/modules/gui/qt/util/pictureflow.cpp
> > index a76a4accb1..551127c2ef 100644
> > --- a/modules/gui/qt/util/pictureflow.cpp
> > +++ b/modules/gui/qt/util/pictureflow.cpp
> > @@ -257,6 +257,13 @@
> > PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer():
> >  PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
> >  {
> >      buffer = QImage();
> > +
> > +    for( QHash<QString, QImage*>::const_iterator
> > +         it = cache.constBegin(); it != cache.constEnd(); ++it )
> > +    {
> > +        delete it.value();
> > +    }
> > +
> >      cache.clear();
> >      delete blankSurface;
> >  }
> > -- 
> > 2.12.0
> > 
> 
> I guess using qDeleteAll would be easier. LGTM otherwise

Ah yeah, that's a very good point; I did not even consider
`QHash::values`at the time when I wrote the patch, that together with
`qDeleteAll` is of course cleaner than what is proposed.

I will also take the opportunity to remove the call to `cache.clear()`
as it does not matter since we are destroying the object which has
`cache` as a member.

Thanks,\
Filip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170301/cf7ecd10/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gui-qt-pictureflow-clear-cache-on-destruction.patch
Type: text/x-diff
Size: 2827 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170301/cf7ecd10/attachment.patch>


More information about the vlc-devel mailing list