Use proper data type for elapsed time

PR #21963.
This commit is contained in:
Chocobo1 2024-12-08 17:02:20 +08:00 committed by GitHub
parent 0ad65ceef6
commit a311c259cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 9 deletions

View file

@ -1601,20 +1601,24 @@ void SessionImpl::endStartup(ResumeSessionContext *context)
m_resumeDataTimer->start();
}
m_wakeupCheckTimer = new QTimer(this);
connect(m_wakeupCheckTimer, &QTimer::timeout, this, [this]
auto wakeupCheckTimer = new QTimer(this);
connect(wakeupCheckTimer, &QTimer::timeout, this, [this]
{
const auto now = std::chrono::steady_clock::now();
if ((now - m_wakeupCheckTimestamp) > 100s)
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
const bool hasSystemSlept = m_wakeupCheckTimestamp.durationElapsed() > 100s;
#else
const bool hasSystemSlept = m_wakeupCheckTimestamp.elapsed() > std::chrono::milliseconds(100s).count();
#endif
if (hasSystemSlept)
{
LogMsg(tr("System wake-up event detected. Re-announcing to all the trackers..."));
reannounceToAllTrackers();
}
m_wakeupCheckTimestamp = now;
m_wakeupCheckTimestamp.start();
});
m_wakeupCheckTimestamp = std::chrono::steady_clock::now();
m_wakeupCheckTimer->start(30s);
m_wakeupCheckTimestamp.start();
wakeupCheckTimer->start(30s);
m_isRestored = true;
emit startupProgressUpdated(100);

View file

@ -823,8 +823,7 @@ namespace BitTorrent
bool m_isPortMappingEnabled = false;
QHash<quint16, std::vector<lt::port_mapping_t>> m_mappedPorts;
QTimer *m_wakeupCheckTimer = nullptr;
std::chrono::steady_clock::time_point m_wakeupCheckTimestamp;
QElapsedTimer m_wakeupCheckTimestamp;
QList<TorrentImpl *> m_pendingFinishedTorrents;