[PATCH] fix khotkey crashes

Thiago Macieira thiago at kde.org
Wed Dec 5 18:05:17 GMT 2007


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();

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071205/4c9c8274/attachment.sig>


More information about the kde-core-devel mailing list