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

List:       kdevelop-devel
Subject:    Re: cpp header organizer
From:       Matt Rogers <mattr () kde ! org>
Date:       2005-01-13 14:51:42
Message-ID: 200501130851.42535.mattr () kde ! org
[Download RAW message or body]

On Thursday 13 January 2005 08:34 am, Felix Berger wrote:
> On Tuesday 11 January 2005 13:40, Roberto Raggi wrote:
> > tnx a lot Felix, I will take a look at it later at home
>
> Hi Roberto,
>
> I found the culprit, it's in my code:
>
>   for (QPtrListIterator<BaseSpecifierAST> i(base->baseSpecifierList());
>        i.current(); ++i) {
>     parseBaseSpecifier(i.current());
>   }
>
> The problem is, that QPtrlist is copied when returned from
> base->baseSpecifierList, this is a "deep" copy in the sense that all item
> references are copied and there is no connection to the original list. But
> since I didn't assign the list to stack variable, it goes out of scope
> immediately, thus invalidating all its iterators.
>
> A working implementation would have to look like this:
>
> QPtrList<BaseSpecifierAST> list(base->baseSpecifierList());
> for (QPtrListIterator<BaseSpecifierAST> i(list);
>        i.current(); ++i) {
>     parseBaseSpecifier(i.current());
>   }
>
> That was a bit tricky, I suppose a QValueList<BaseSpecifierAST*> would
> yield a more intuitive behaviour since all instances reference the same
> internal list when copied. Don't know about autodeleting the items though.
>

QValueList would behave the same way wrt to the iterators becoming invalid 
after the list goes out of scope IIRC


_______________________________________________
KDevelop-devel mailing list
KDevelop-devel@barney.cs.uni-potsdam.de
http://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

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