ProtocolWidget: limit the number of items

That should save memory instead of letting the number of items grow
to infinity
This commit is contained in:
Olivier Goffart 2014-07-08 21:52:57 +02:00
parent 82c254fecf
commit 63cd5ef563

View file

@ -131,6 +131,13 @@ void ProtocolWidget::slotClearBlacklist()
void ProtocolWidget::cleanIgnoreItems(const QString& folder)
{
int itemCnt = _ui->_treeWidget->topLevelItemCount();
// Limit the number of items
while(itemCnt > 2000) {
delete _ui->_treeWidget->takeTopLevelItem(itemCnt - 1);
itemCnt--;
}
for( int cnt = itemCnt-1; cnt >=0 ; cnt-- ) {
QTreeWidgetItem *item = _ui->_treeWidget->topLevelItem(cnt);
bool isErrorItem = item->data(0, IgnoredIndicatorRole).toBool();