diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 1fa78ff83..a4f2e25fa 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -113,6 +113,8 @@ Folder::Folder(const FolderDefinition& definition, Folder::~Folder() { + // Reset then engine first as it will abort and try to access members of the Folder + _engine.reset(); } void Folder::checkLocalPath() 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); } } diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index 5875ae739..f60106244 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -234,6 +234,8 @@ void PropagateUploadFileQNAM::slotComputeContentChecksum() connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray))); + connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), + computeChecksum, SLOT(deleteLater())); computeChecksum->start(filePath); } @@ -268,6 +270,8 @@ void PropagateUploadFileQNAM::slotComputeTransmissionChecksum(const QByteArray& connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), SLOT(slotStartUpload(QByteArray,QByteArray))); + connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), + computeChecksum, SLOT(deleteLater())); const QString filePath = _propagator->getFilePath(_item->_file); computeChecksum->start(filePath); } @@ -775,6 +779,8 @@ void PropagateUploadFileQNAM::slotPutFinished() << _stopWatch.durationOfLap(QLatin1String("ContentChecksum")) << _stopWatch.durationOfLap(QLatin1String("TransmissionChecksum")) << _item->_requestDuration; + // The job might stay alive for the whole sync, release this tiny bit of memory. + _stopWatch.reset(); finalize(*_item); } diff --git a/src/libsync/utility.h b/src/libsync/utility.h index 044988fe1..6dd2f1788 100644 --- a/src/libsync/utility.h +++ b/src/libsync/utility.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace OCC { @@ -121,7 +121,7 @@ namespace Utility class OWNCLOUDSYNC_EXPORT StopWatch { private: - QHash _lapTimes; + QMap _lapTimes; QDateTime _startTime; QElapsedTimer _timer; public: