[plasma-framework] src/plasma: plasma: Fix applet actions might be nullptr

Martin Klapetek martin.klapetek at gmail.com
Wed Sep 2 15:23:15 UTC 2015


On Wed, Aug 26, 2015 at 5:38 AM, Christoph Feck <cfeck at kde.org> wrote:

> On Wednesday 26 August 2015 11:27:05 Leslie Zhai wrote:
> > Git commit 4e9b32d80d6b43ad3d1ddd47c948ad066608b052 by Leslie
> Zhai.
> > Committed on 26/08/2015 at 09:24.
> > Pushed by lesliezhai into branch 'master'.
> >
> > plasma: Fix applet actions might be nullptr
> > BUG:351777
> >
> > M  +1    -1    src/plasma/applet.cpp
> >
> > http://commits.kde.org/plasma-framework/4e9b32d80d6b43ad3d1ddd47c94
> > 8ad066608b052
> >
> > diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp
> > index 895555c..3716a83 100644
> > --- a/src/plasma/applet.cpp
> > +++ b/src/plasma/applet.cpp
> > @@ -568,7 +568,7 @@ QList<QAction *> Applet::contextualActions()
> >
> >  KActionCollection *Applet::actions() const
> >  {
> > -    return d->actions;
> > +    return d->actions ? d->actions : new
> > KActionCollection((QObject *)this); }
> >
> >  Types::FormFactor Applet::formFactor() const
>
> Doesn't this leak memory? I doubt the caller of Applet::actions() is
> supposed to delete the received pointer.
>

It does I think. It should be assigned back to d->actions however if
d->actions is null here, there's something else wrong because the
default d->actions collection is created in ::Private constructor. So
while this patch does fix the crash, I don't think it's the correct fix.

It would certainly help if Leslie provided some explanation for this
patch.

Leslie?

Can we also please ask to have patches submitted to reviewboard
first?

Cheers
-- 
Martin Klapetek | KDE Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20150902/04bed3cc/attachment.html>


More information about the Plasma-devel mailing list