mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Use QElapsedTimer
This commit is contained in:
parent
2aea235e34
commit
f2957c721d
@ -329,6 +329,8 @@ SyncController::SyncController(ISessionManager *sessionManager, QObject *parent)
|
||||
connect(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::checked, this, &SyncController::freeDiskSpaceSizeUpdated);
|
||||
|
||||
m_freeDiskSpaceThread->start();
|
||||
QTimer::singleShot(0, m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::check);
|
||||
m_freeDiskSpaceElapsedTimer.start();
|
||||
}
|
||||
|
||||
SyncController::~SyncController()
|
||||
@ -512,11 +514,11 @@ void SyncController::torrentPeersAction()
|
||||
|
||||
qint64 SyncController::getFreeDiskSpace()
|
||||
{
|
||||
const qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
if ((now - m_freeDiskSpaceLastUpdate) >= FREEDISKSPACE_CHECK_TIMEOUT) {
|
||||
if (m_freeDiskSpaceElapsedTimer.hasExpired(FREEDISKSPACE_CHECK_TIMEOUT)) {
|
||||
QTimer::singleShot(0, m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::check);
|
||||
m_freeDiskSpaceLastUpdate = now;
|
||||
m_freeDiskSpaceElapsedTimer.restart();
|
||||
}
|
||||
|
||||
return m_freeDiskSpace;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "apicontroller.h"
|
||||
|
||||
struct ISessionManager;
|
||||
@ -56,7 +58,7 @@ private:
|
||||
qint64 getFreeDiskSpace();
|
||||
|
||||
qint64 m_freeDiskSpace = 0;
|
||||
qint64 m_freeDiskSpaceLastUpdate = 0;
|
||||
FreeDiskSpaceChecker *m_freeDiskSpaceChecker = nullptr;
|
||||
QThread *m_freeDiskSpaceThread = nullptr;
|
||||
QElapsedTimer m_freeDiskSpaceElapsedTimer;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user