[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Problem with QT
From:       André_Wöbbeking <Woebbeking () onlinehome ! de>
Date:       2005-10-22 8:40:52
Message-ID: 200510221040.53024.Woebbeking () onlinehome ! de
[Download RAW message or body]

On Saturday 22 October 2005 09:27, Bernd Brandstetter wrote:
> On Saturday 22 October 2005 00:46, David Faure wrote:
> > > And for a perhaps more useful answer, add a destructor for
> > > KgpgListKeys that iterates over its keys and deletes them.  You
> > > might not be able to use foreach() since the dtor will be
> > > iterating over itself but something like this would work:
> > >
> > > KgpgListKeys::~KgpgListKeys()
> > > {
> > >   for(ConstIterator it = constBegin(); it != constEnd(); ++it)
> > >   {
> > >     delete *it;
> > >   }
> >
> > qDeleteAll(this) should do the same as the above code.
>
> But be very careful when putting this in the destructor. If somebody
> iterates this list using foreach(), he will end up with all elements
> being deleted after the loop - which is most probably not what he
> expected.

??? 

If an object (in the case the the list) was destructed you MUST NOT use 
it anymore.


Cheers,
André
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic