my code:
QList<QTreeWidgetItem*>::iterator itd = itemsToDelete.begin();
while (itd != itemsToDelete.end())
{
if (!twi_->childCount())
{
cout <<twi_<<"-"<<twi_->childCount()<<endl; //log1
cout <<twi_->text(0).toStdString()<<endl; //log2
delete twi_;
twi_ = 0;
//twi_->setText(0, "ChangeText"); //if comment "delete twi_;" this line work
cout <<"ok"<<endl;
itd = itemsToDelete.erase(itd);
cout <<"from List ok"<<endl;
}
else
++itd;
}
QList<QTreeWidgetItem*>::iterator itd = itemsToDelete.begin();
while (itd != itemsToDelete.end())
{
QTreeWidgetItem* twi_ = *itd;
if (!twi_->childCount())
{
cout <<twi_<<"-"<<twi_->childCount()<<endl; //log1
cout <<twi_->text(0).toStdString()<<endl; //log2
delete twi_;
twi_ = 0;
//twi_->setText(0, "ChangeText"); //if comment "delete twi_;" this line work
cout <<"ok"<<endl;
itd = itemsToDelete.erase(itd);
cout <<"from List ok"<<endl;
}
else
++itd;
}
To copy to clipboard, switch view to plain text mode
now program log:
log1: 0x41617880-0 //normal - no children
log2: itemText // it's right too;
on line "delete twi_;" program crash (debugger mark this line too)
why it can be possible?
P.S my qt version 4.1.4
more precise: crashing only for non topLevelItems
Bookmarks