From: V.C Date: Fri, 21 Aug 2020 00:03:29 +0000 (+0000) Subject: Support client builds on VS2019 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~207^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=af1bb7e98ca7b1f001c11bd72581c610eee669f9;p=nextcloud-desktop.git Support client builds on VS2019 Scenario: Build fails on Qt 5.15.0 + VS2019 16.7.2 Root cause: QLinkedList seems to be depreciated. Advise to use std::list instead. Fix: Used std::list insead of QLinkedList. Signed-off-by: V.C --- diff --git a/src/libsync/bandwidthmanager.cpp b/src/libsync/bandwidthmanager.cpp index 63ea83d3c..edeeb196e 100644 --- a/src/libsync/bandwidthmanager.cpp +++ b/src/libsync/bandwidthmanager.cpp @@ -91,8 +91,8 @@ BandwidthManager::~BandwidthManager() = default; void BandwidthManager::registerUploadDevice(UploadDevice *p) { - _absoluteUploadDeviceList.append(p); - _relativeUploadDeviceList.append(p); + _absoluteUploadDeviceList.push_back(p); + _relativeUploadDeviceList.push_back(p); QObject::connect(p, &QObject::destroyed, this, &BandwidthManager::unregisterUploadDevice); if (usingAbsoluteUploadLimit()) { @@ -110,8 +110,8 @@ void BandwidthManager::registerUploadDevice(UploadDevice *p) void BandwidthManager::unregisterUploadDevice(QObject *o) { auto p = reinterpret_cast(o); // note, we might already be in the ~QObject - _absoluteUploadDeviceList.removeAll(p); - _relativeUploadDeviceList.removeAll(p); + _absoluteUploadDeviceList.remove(p); + _relativeUploadDeviceList.remove(p); if (p == _relativeLimitCurrentMeasuredDevice) { _relativeLimitCurrentMeasuredDevice = nullptr; _relativeUploadLimitProgressAtMeasuringRestart = 0; @@ -120,7 +120,7 @@ void BandwidthManager::unregisterUploadDevice(QObject *o) void BandwidthManager::registerDownloadJob(GETFileJob *j) { - _downloadJobList.append(j); + _downloadJobList.push_back(j); QObject::connect(j, &QObject::destroyed, this, &BandwidthManager::unregisterDownloadJob); if (usingAbsoluteDownloadLimit()) { @@ -138,7 +138,7 @@ void BandwidthManager::registerDownloadJob(GETFileJob *j) void BandwidthManager::unregisterDownloadJob(QObject *o) { auto *j = reinterpret_cast(o); // note, we might already be in the ~QObject - _downloadJobList.removeAll(j); + _downloadJobList.remove(j); if (_relativeLimitCurrentMeasuredJob == j) { _relativeLimitCurrentMeasuredJob = nullptr; _relativeDownloadLimitProgressAtMeasuringRestart = 0; @@ -147,7 +147,7 @@ void BandwidthManager::unregisterDownloadJob(QObject *o) void BandwidthManager::relativeUploadMeasuringTimerExpired() { - if (!usingRelativeUploadLimit() || _relativeUploadDeviceList.count() == 0) { + if (!usingRelativeUploadLimit() || _relativeUploadDeviceList.size() == 0) { // Not in this limiting mode, just wait 1 sec to continue the cycle _relativeUploadDelayTimer.setInterval(1000); _relativeUploadDelayTimer.start(); @@ -160,7 +160,7 @@ void BandwidthManager::relativeUploadMeasuringTimerExpired() return; } - qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.count() << "Starting Delay"; + qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.size() << "Starting Delay"; qint64 relativeLimitProgressMeasured = (_relativeLimitCurrentMeasuredDevice->_readWithProgress + _relativeLimitCurrentMeasuredDevice->_read) @@ -191,7 +191,7 @@ void BandwidthManager::relativeUploadMeasuringTimerExpired() _relativeUploadDelayTimer.setInterval(realWaitTimeMsec); _relativeUploadDelayTimer.start(); - int deviceCount = _relativeUploadDeviceList.count(); + size_t deviceCount = _relativeUploadDeviceList.size(); qint64 quotaPerDevice = relativeLimitProgressDifference * (uploadLimitPercent / 100.0) / deviceCount + 1.0; Q_FOREACH (UploadDevice *ud, _relativeUploadDeviceList) { ud->setBandwidthLimited(true); @@ -211,15 +211,16 @@ void BandwidthManager::relativeUploadDelayTimerExpired() return; // oh, not actually needed } - if (_relativeUploadDeviceList.isEmpty()) { + if (_relativeUploadDeviceList.empty()) { return; } - qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.count() << "Starting measuring"; + qCDebug(lcBandwidthManager) << _relativeUploadDeviceList.size() << "Starting measuring"; // Take first device and then append it again (= we round robin all devices) - _relativeLimitCurrentMeasuredDevice = _relativeUploadDeviceList.takeFirst(); - _relativeUploadDeviceList.append(_relativeLimitCurrentMeasuredDevice); + _relativeLimitCurrentMeasuredDevice = _relativeUploadDeviceList.front(); + _relativeUploadDeviceList.pop_front(); + _relativeUploadDeviceList.push_back(_relativeLimitCurrentMeasuredDevice); _relativeUploadLimitProgressAtMeasuringRestart = (_relativeLimitCurrentMeasuredDevice->_readWithProgress + _relativeLimitCurrentMeasuredDevice->_read) @@ -241,7 +242,7 @@ void BandwidthManager::relativeUploadDelayTimerExpired() // for downloads: void BandwidthManager::relativeDownloadMeasuringTimerExpired() { - if (!usingRelativeDownloadLimit() || _downloadJobList.count() == 0) { + if (!usingRelativeDownloadLimit() || _downloadJobList.size() == 0) { // Not in this limiting mode, just wait 1 sec to continue the cycle _relativeDownloadDelayTimer.setInterval(1000); _relativeDownloadDelayTimer.start(); @@ -254,7 +255,7 @@ void BandwidthManager::relativeDownloadMeasuringTimerExpired() return; } - qCDebug(lcBandwidthManager) << _downloadJobList.count() << "Starting Delay"; + qCDebug(lcBandwidthManager) << _downloadJobList.size() << "Starting Delay"; qint64 relativeLimitProgressMeasured = _relativeLimitCurrentMeasuredJob->currentDownloadPosition(); qint64 relativeLimitProgressDifference = relativeLimitProgressMeasured - _relativeDownloadLimitProgressAtMeasuringRestart; @@ -280,7 +281,7 @@ void BandwidthManager::relativeDownloadMeasuringTimerExpired() _relativeDownloadDelayTimer.setInterval(realWaitTimeMsec); _relativeDownloadDelayTimer.start(); - int jobCount = _downloadJobList.count(); + size_t jobCount = _downloadJobList.size(); qint64 quota = relativeLimitProgressDifference * (downloadLimitPercent / 100.0); if (quota > 20 * 1024) { qCInfo(lcBandwidthManager) << "ADJUSTING QUOTA FROM " << quota << " TO " << quota - 20 * 1024; @@ -305,16 +306,17 @@ void BandwidthManager::relativeDownloadDelayTimerExpired() return; // oh, not actually needed } - if (_downloadJobList.isEmpty()) { - qCDebug(lcBandwidthManager) << _downloadJobList.count() << "No jobs?"; + if (_downloadJobList.empty()) { + qCDebug(lcBandwidthManager) << _downloadJobList.size() << "No jobs?"; return; } - qCDebug(lcBandwidthManager) << _downloadJobList.count() << "Starting measuring"; + qCDebug(lcBandwidthManager) << _downloadJobList.size() << "Starting measuring"; // Take first device and then append it again (= we round robin all devices) - _relativeLimitCurrentMeasuredJob = _downloadJobList.takeFirst(); - _downloadJobList.append(_relativeLimitCurrentMeasuredJob); + _relativeLimitCurrentMeasuredJob = _downloadJobList.front(); + _downloadJobList.pop_front(); + _downloadJobList.push_back(_relativeLimitCurrentMeasuredJob); _relativeDownloadLimitProgressAtMeasuringRestart = _relativeLimitCurrentMeasuredJob->currentDownloadPosition(); _relativeLimitCurrentMeasuredJob->setBandwidthLimited(false); @@ -373,17 +375,17 @@ void BandwidthManager::switchingTimerExpired() void BandwidthManager::absoluteLimitTimerExpired() { - if (usingAbsoluteUploadLimit() && _absoluteUploadDeviceList.count() > 0) { - qint64 quotaPerDevice = _currentUploadLimit / qMax(1, _absoluteUploadDeviceList.count()); - qCDebug(lcBandwidthManager) << quotaPerDevice << _absoluteUploadDeviceList.count() << _currentUploadLimit; + if (usingAbsoluteUploadLimit() && _absoluteUploadDeviceList.size() > 0) { + qint64 quotaPerDevice = _currentUploadLimit / qMax((std::list::size_type)1, _absoluteUploadDeviceList.size()); + qCDebug(lcBandwidthManager) << quotaPerDevice << _absoluteUploadDeviceList.size() << _currentUploadLimit; Q_FOREACH (UploadDevice *device, _absoluteUploadDeviceList) { device->giveBandwidthQuota(quotaPerDevice); qCDebug(lcBandwidthManager) << "Gave " << quotaPerDevice / 1024.0 << " kB to" << device; } } - if (usingAbsoluteDownloadLimit() && _downloadJobList.count() > 0) { - qint64 quotaPerJob = _currentDownloadLimit / qMax(1, _downloadJobList.count()); - qCDebug(lcBandwidthManager) << quotaPerJob << _downloadJobList.count() << _currentDownloadLimit; + if (usingAbsoluteDownloadLimit() && _downloadJobList.size() > 0) { + qint64 quotaPerJob = _currentDownloadLimit / qMax((std::list::size_type)1, _downloadJobList.size()); + qCDebug(lcBandwidthManager) << quotaPerJob << _downloadJobList.size() << _currentDownloadLimit; Q_FOREACH (GETFileJob *j, _downloadJobList) { j->giveBandwidthQuota(quotaPerJob); qCDebug(lcBandwidthManager) << "Gave " << quotaPerJob / 1024.0 << " kB to" << j; diff --git a/src/libsync/bandwidthmanager.h b/src/libsync/bandwidthmanager.h index 691e11162..15d949fbc 100644 --- a/src/libsync/bandwidthmanager.h +++ b/src/libsync/bandwidthmanager.h @@ -16,9 +16,9 @@ #define BANDWIDTHMANAGER_H #include -#include #include #include +#include namespace OCC { @@ -71,8 +71,8 @@ private: QTimer _absoluteLimitTimer; // FIXME merge these two lists - QLinkedList _absoluteUploadDeviceList; - QLinkedList _relativeUploadDeviceList; + std::list _absoluteUploadDeviceList; + std::list _relativeUploadDeviceList; QTimer _relativeUploadMeasuringTimer; @@ -86,7 +86,7 @@ private: qint64 _relativeUploadLimitProgressAtMeasuringRestart; qint64 _currentUploadLimit; - QLinkedList _downloadJobList; + std::list _downloadJobList; QTimer _relativeDownloadMeasuringTimer; // for relative bw limiting, we need to wait this amount before measuring again