Skip to content

Commit

Permalink
Use proper data type for elapsed time
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed Dec 6, 2024
1 parent 2d1c4fc commit 2818cf3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 11 additions & 7 deletions src/base/bittorrent/sessionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/base/bittorrent/sessionimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,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;

Expand Down

0 comments on commit 2818cf3

Please sign in to comment.