mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-06 15:42:32 -06:00
Fill in initial data in add_torrent_alert handler
libtorrent < 2.0.7 has a bug that add_torrent_alert is posted too early (before torrent is fully initialized and torrent extensions are created) so we have to fill initial torrent data in add_torrent_alert handler. PR #17491.
This commit is contained in:
committed by
GitHub
parent
33e6ca6778
commit
7f40602da9
@@ -42,14 +42,22 @@ NativeTorrentExtension::NativeTorrentExtension(const lt::torrent_handle &torrent
|
||||
: m_torrentHandle {torrentHandle}
|
||||
, m_data {data}
|
||||
{
|
||||
lt::torrent_status torrentStatus = m_torrentHandle.status({});
|
||||
on_state(torrentStatus.state);
|
||||
// NOTE: `data` may not exist if a torrent is added behind the scenes to download metadata
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
// libtorrent < 2.0.7 has a bug that add_torrent_alert is posted too early
|
||||
// (before torrent is fully initialized and torrent extensions are created)
|
||||
// so we have to fill "extension data" in add_torrent_alert handler and
|
||||
// we have it already filled at this point
|
||||
|
||||
if (m_data)
|
||||
{
|
||||
m_data->status = std::move(torrentStatus);
|
||||
m_data->status = m_torrentHandle.status({});
|
||||
m_data->trackers = m_torrentHandle.trackers();
|
||||
}
|
||||
#endif
|
||||
|
||||
on_state(m_data ? m_data->status.state : m_torrentHandle.status({}).state);
|
||||
}
|
||||
|
||||
NativeTorrentExtension::~NativeTorrentExtension()
|
||||
|
||||
Reference in New Issue
Block a user