Discard obsolete "state update" events after torrent is reloaded

PR #21873.
Closes #21827.
This commit is contained in:
Vladimir Golovnev
2024-11-21 13:56:22 +03:00
committed by Vladimir Golovnev (glassez)
parent ac9ca4f452
commit 71b752baf3

View File

@@ -2625,6 +2625,12 @@ bool TorrentImpl::isMoveInProgress() const
void TorrentImpl::updateStatus(const lt::torrent_status &nativeStatus) void TorrentImpl::updateStatus(const lt::torrent_status &nativeStatus)
{ {
// Since libtorrent alerts are handled asynchronously there can be obsolete
// "state update" event reached here after torrent was reloaded in libtorrent.
// Just discard such events.
if (nativeStatus.handle != m_nativeHandle) [[unlikely]]
return;
const lt::torrent_status oldStatus = std::exchange(m_nativeStatus, nativeStatus); const lt::torrent_status oldStatus = std::exchange(m_nativeStatus, nativeStatus);
if (m_nativeStatus.num_pieces != oldStatus.num_pieces) if (m_nativeStatus.num_pieces != oldStatus.num_pieces)