[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: QStringList problem
From: Thiago Macieira <thiago () kde ! org>
Date: 2006-11-17 22:21:47
Message-ID: 200611172321.48327.thiago () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
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();
> 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;
> }
>############################
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
[Attachment #5 (application/pgp-signature)]
>> 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