diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-06-17 20:06:39 +0300 |
---|---|---|
committer | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-06-17 20:20:53 +0300 |
commit | 87e3553c850348721bd371b32d72bfbb55b58586 (patch) | |
tree | 2cce801b20168a99c0510ddc4073866548561937 /src/gui/protocolwidget.cpp | |
parent | 6f3aaecb783c5d8b9dc82cb9752ec4d0372a3b9c (diff) |
Prevent the sync protocol widget from over-using memory
During propagation, we create a line for each file, taking memory, but
we delete all lines passed 2000 right at the beginning of the next sync.
Since the user has little chances of being able to read past those 2000
lines in the log, we might as well keep it capped at 2000 also during
propagation to prevent it from eating memory.
Diffstat (limited to 'src/gui/protocolwidget.cpp')
-rw-r--r-- | src/gui/protocolwidget.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gui/protocolwidget.cpp b/src/gui/protocolwidget.cpp index c96fa1de3..8955dc7b7 100644 --- a/src/gui/protocolwidget.cpp +++ b/src/gui/protocolwidget.cpp @@ -121,17 +121,9 @@ void ProtocolWidget::hideEvent(QHideEvent *ev) void ProtocolWidget::cleanItems(const QString& folder) { - int itemCnt = _ui->_treeWidget->topLevelItemCount(); - - // Limit the number of items - while(itemCnt > 2000) { - delete _ui->_treeWidget->takeTopLevelItem(itemCnt - 1); - itemCnt--; - } - // The issue list is a state, clear it and let the next sync fill it // with ignored files and propagation errors. - itemCnt = _issueItemView->topLevelItemCount(); + int itemCnt = _issueItemView->topLevelItemCount(); for( int cnt = itemCnt-1; cnt >=0 ; cnt-- ) { QTreeWidgetItem *item = _issueItemView->topLevelItem(cnt); QString itemFolder = item->data(2, Qt::UserRole).toString(); @@ -239,6 +231,12 @@ void ProtocolWidget::slotItemCompleted(const QString &folder, const SyncFileItem _issueItemView->insertTopLevelItem(0, line); emit issueItemCountUpdated(_issueItemView->topLevelItemCount()); } else { + // Limit the number of items + int itemCnt = _ui->_treeWidget->topLevelItemCount(); + while(itemCnt > 2000) { + delete _ui->_treeWidget->takeTopLevelItem(itemCnt - 1); + itemCnt--; + } _ui->_treeWidget->insertTopLevelItem(0, line); } } |