mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
parent
d29f47c36e
commit
dcaf4b6d80
4 changed files with 21 additions and 19 deletions
|
@ -409,8 +409,11 @@ void PeerListWidget::loadPeers(const BitTorrent::Torrent *torrent)
|
|||
using TorrentPtr = QPointer<const BitTorrent::Torrent>;
|
||||
torrent->fetchPeerInfo().then(this, [this, torrent = TorrentPtr(torrent)](const QList<BitTorrent::PeerInfo> &peers)
|
||||
{
|
||||
if (torrent != m_properties->getCurrentTorrent())
|
||||
if (const BitTorrent::Torrent *currentTorrent = m_properties->getCurrentTorrent();
|
||||
!currentTorrent || (currentTorrent != torrent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove I2P peers since they will be completely reloaded.
|
||||
for (const QStandardItem *item : asConst(m_I2PPeerItems))
|
||||
|
|
|
@ -480,9 +480,10 @@ void PropertiesWidget::loadDynamicData()
|
|||
showPiecesAvailability(true);
|
||||
|
||||
using TorrentPtr = QPointer<BitTorrent::Torrent>;
|
||||
m_torrent->fetchPieceAvailability().then(this, [this, torrent = TorrentPtr(m_torrent)](const QList<int> &pieceAvailability)
|
||||
m_torrent->fetchPieceAvailability().then(this
|
||||
, [this, torrent = TorrentPtr(m_torrent)](const QList<int> &pieceAvailability)
|
||||
{
|
||||
if (torrent == m_torrent)
|
||||
if (m_torrent && (m_torrent == torrent))
|
||||
m_piecesAvailability->setAvailability(pieceAvailability);
|
||||
});
|
||||
|
||||
|
@ -497,9 +498,12 @@ void PropertiesWidget::loadDynamicData()
|
|||
qreal progress = m_torrent->progress() * 100.;
|
||||
m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + u'%');
|
||||
|
||||
m_torrent->fetchDownloadingPieces().then(this, [this](const QBitArray &downloadingPieces)
|
||||
using TorrentPtr = QPointer<BitTorrent::Torrent>;
|
||||
m_torrent->fetchDownloadingPieces().then(this
|
||||
, [this, torrent = TorrentPtr(m_torrent)](const QBitArray &downloadingPieces)
|
||||
{
|
||||
m_downloadedPieces->setProgress(m_torrent->pieces(), downloadingPieces);
|
||||
if (m_torrent && (m_torrent == torrent))
|
||||
m_downloadedPieces->setProgress(m_torrent->pieces(), downloadingPieces);
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -527,7 +531,7 @@ void PropertiesWidget::loadUrlSeeds()
|
|||
using TorrentPtr = QPointer<BitTorrent::Torrent>;
|
||||
m_torrent->fetchURLSeeds().then(this, [this, torrent = TorrentPtr(m_torrent)](const QList<QUrl> &urlSeeds)
|
||||
{
|
||||
if (torrent != m_torrent)
|
||||
if (!m_torrent || (m_torrent != torrent))
|
||||
return;
|
||||
|
||||
m_ui->listWebSeeds->clear();
|
||||
|
|
|
@ -223,16 +223,11 @@ void TorrentContentModel::updateFilesAvailability()
|
|||
m_contentHandler->fetchAvailableFileFractions().then(this
|
||||
, [this, handler = HandlerPtr(m_contentHandler)](const QList<qreal> &availableFileFractions)
|
||||
{
|
||||
if (handler != m_contentHandler)
|
||||
return;
|
||||
|
||||
Q_ASSERT(m_filesIndex.size() == availableFileFractions.size());
|
||||
// XXX: Why is this necessary?
|
||||
if (m_filesIndex.size() != availableFileFractions.size()) [[unlikely]]
|
||||
if (!m_contentHandler || (m_contentHandler != handler))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < m_filesIndex.size(); ++i)
|
||||
m_filesIndex[i]->setAvailability(availableFileFractions[i]);
|
||||
m_filesIndex[i]->setAvailability(availableFileFractions.value(i, 0));
|
||||
// Update folders progress in the tree
|
||||
m_rootItem->recalculateProgress();
|
||||
});
|
||||
|
|
|
@ -312,14 +312,14 @@ void TrackerListModel::populate()
|
|||
using TorrentPtr = QPointer<const BitTorrent::Torrent>;
|
||||
m_torrent->fetchPeerInfo().then(this, [this, torrent = TorrentPtr(m_torrent)](const QList<BitTorrent::PeerInfo> &peers)
|
||||
{
|
||||
if (torrent != m_torrent)
|
||||
if (!m_torrent || (m_torrent != torrent))
|
||||
return;
|
||||
|
||||
// XXX: libtorrent should provide this info...
|
||||
// Count peers from DHT, PeX, LSD
|
||||
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, peersDHT = 0, peersPeX = 0, peersLSD = 0;
|
||||
for (const BitTorrent::PeerInfo &peer : peers)
|
||||
{
|
||||
// XXX: libtorrent should provide this info...
|
||||
// Count peers from DHT, PeX, LSD
|
||||
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, peersDHT = 0, peersPeX = 0, peersLSD = 0;
|
||||
for (const BitTorrent::PeerInfo &peer : peers)
|
||||
{
|
||||
if (peer.isConnecting())
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue