Hi,
ANKIT GANDHI wrote:
> for (std::list<Contact>::const_iterator it =
> _contactList->getContacts().begin();
> it != _contactList->getContacts().end();
> *it++* /*<<-- Suspect of crashing qutecom*/)
> {
>
> LOG_INFO("temp log");
>
> if(it->getContactType()=="Auto")
> {
> LOG_INFO("removing : " + it->getUUID());
>
> _contactList->removeContact(*_contactList->getContact(it->getUUID()));
> }
> }
>
> Now when this for loop executes, first loop it goes well, now when it
> does it++ and tries to iterate to next contact, qutecom crashes. So can
> anyone suggest me any idea how can I iterate over the contacts, check
> some condition of contact and remove those ?
If you remove the contact referenced by "it", the iterator will no
longer be valid, So you need to increment it before removing the element.
Something like:
if(it->getContactType()=="Auto")
{
_contactList->removeContact(*_contactList->getContact(it++->getUUID()));
}
else
++it;
And remove the increment operation on "it" from the for loop.
HTH,
Cheers,
Ludovico
_______________________________________________
QuteCom-dev mailing list
[email protected]
http://lists.qutecom.org/mailman/listinfo/qutecom-dev