Browse Source

Avoid using deprecated stats_alert

From libtorrent doc:
This alert has been superseded by calling post_torrent_updates() regularly on the session object.
adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
0fe9cd05c4
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 10
      src/base/bittorrent/session.cpp
  2. 14
      src/base/bittorrent/torrenthandle.cpp
  3. 1
      src/base/bittorrent/torrenthandle.h

10
src/base/bittorrent/session.cpp

@ -386,7 +386,6 @@ Session::Session(QObject *parent) @@ -386,7 +386,6 @@ Session::Session(QObject *parent)
| lt::alert::status_notification
| lt::alert::ip_block_notification
| lt::alert::performance_warning
| lt::alert::stats_notification
| lt::alert::file_progress_notification;
const std::string peerId = lt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
@ -4280,12 +4279,15 @@ void Session::handleStateUpdateAlert(const lt::state_update_alert *p) @@ -4280,12 +4279,15 @@ void Session::handleStateUpdateAlert(const lt::state_update_alert *p)
{
for (const lt::torrent_status &status : p->status) {
TorrentHandle *const torrent = m_torrents.value(status.info_hash);
if (torrent)
torrent->handleStateUpdate(status);
if (!torrent)
continue;
torrent->handleStateUpdate(status);
}
m_torrentStatusReport = TorrentStatusReport();
for (TorrentHandle *const torrent : asConst(m_torrents)) {
for (const TorrentHandle *torrent : asConst(m_torrents)) {
if (torrent->isDownloading())
++m_torrentStatusReport.nbDownloading;
if (torrent->isUploading())

14
src/base/bittorrent/torrenthandle.cpp

@ -1799,14 +1799,6 @@ void TorrentHandle::handleFileCompletedAlert(const lt::file_completed_alert *p) @@ -1799,14 +1799,6 @@ void TorrentHandle::handleFileCompletedAlert(const lt::file_completed_alert *p)
}
}
void TorrentHandle::handleStatsAlert(const lt::stats_alert *p)
{
Q_ASSERT(p->interval >= 1000);
const SpeedSample transferred(p->transferred[lt::stats_alert::download_payload] * 1000LL / p->interval,
p->transferred[lt::stats_alert::upload_payload] * 1000LL / p->interval);
m_speedMonitor.addSample(transferred);
}
void TorrentHandle::handleMetadataReceivedAlert(const lt::metadata_received_alert *p)
{
Q_UNUSED(p);
@ -1862,9 +1854,6 @@ void TorrentHandle::handleAppendExtensionToggled() @@ -1862,9 +1854,6 @@ void TorrentHandle::handleAppendExtensionToggled()
void TorrentHandle::handleAlert(const lt::alert *a)
{
switch (a->type()) {
case lt::stats_alert::alert_type:
handleStatsAlert(static_cast<const lt::stats_alert*>(a));
break;
case lt::file_renamed_alert::alert_type:
handleFileRenamedAlert(static_cast<const lt::file_renamed_alert*>(a));
break;
@ -2013,6 +2002,9 @@ void TorrentHandle::updateStatus(const lt::torrent_status &nativeStatus) @@ -2013,6 +2002,9 @@ void TorrentHandle::updateStatus(const lt::torrent_status &nativeStatus)
m_unchecked = false;
else if (isDownloading())
m_unchecked = true;
m_speedMonitor.addSample({nativeStatus.download_payload_rate
, nativeStatus.upload_payload_rate});
}
void TorrentHandle::setRatioLimit(qreal limit)

1
src/base/bittorrent/torrenthandle.h

@ -368,7 +368,6 @@ namespace BitTorrent @@ -368,7 +368,6 @@ namespace BitTorrent
void handlePerformanceAlert(const lt::performance_alert *p) const;
void handleSaveResumeDataAlert(const lt::save_resume_data_alert *p);
void handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p);
void handleStatsAlert(const lt::stats_alert *p);
void handleStorageMovedAlert(const lt::storage_moved_alert *p);
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
void handleTorrentCheckedAlert(const lt::torrent_checked_alert *p);

Loading…
Cancel
Save