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

List:       kde-devel
Subject:    Re: QStringList problem
From:       Christian Schaarschmidt <schaarsc () gmx ! de>
Date:       2006-11-17 22:43:52
Message-ID: 200611172343.52680.schaarsc () gmx ! de
[Download RAW message or body]

Am Freitag, 17. November 2006 23:21 schrieb Thiago Macieira:
> Christian Schaarschmidt wrote:
> >Hi,
> >
> >I have a little problem with QStringList from qt-copy.
> >Has anybody seen such behaviour before and can give me some advice or
> >workaround?
>
> Try valgrind. You have dangling pointers.
>
> All iterators are invalidated when you change the container.
>
> >########### small example ################
> >  QStringList l;
> >  l << "item";
> >  QStringList::Iterator iter = l.begin();
> >  kDebug(0)<<"iter before insert="<<*iter<<endl;
> >  l.insert( iter, "ins" );
>
> "iter" is invalidated at this point. You have to start again from
> l.begin();
>

has that changed in QT4? With QT3 I get

kmail: iter before insert=item
kmail: iter after insert=item
kmail: iter at the end



> >  kDebug(0)<<"iter after insert="<<*iter<<endl;
> >  ++iter;
> >  if ( iter == l.end() ) {
> >    kDebug(0) << "iter at the end"<<endl;
> >  } else {
> >    kDebug(0) << "iter not at the end" <<endl;
> >    kDebug(0) << *iter << endl;
> >  }
> >############################
 
>> 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