[PATCH] fix khotkey crashes
Andreas Pakulat
apaku at gmx.de
Wed Dec 5 18:18:33 GMT 2007
On 05.12.07 19:05:17, Thiago Macieira wrote:
> On Wednesday 05 December 2007 18:37:56 Andreas Pakulat wrote:
> > > - while( list.first())
> > > - delete list.first();
> > > + if( !list.isEmpty() )
> > > + {
> > > + while( list.first())
> > > + delete list.first();
> > > + }
> > >
> > > This doesn't make sense.
> >
> > It does, check your QList docs. first() doesn't work properly when the
> > list is empty (in debug builds it asserts).
>
> True, but the patch doesn't make sense.
>
> That is going to enter an infinite-loop deleting the same pointer over and
> over again.
>
> You probably wanted:
> while (!list.isEmpty())
> delete list.takeFirst();
>
> or, more cleanly:
> qDeleteAll(list);
> list.clear();
Right, Oswald just kicked my brain into place so I can actually understand
the problems :)
Andreas
--
Caution: Keep out of reach of children.
More information about the kde-core-devel
mailing list