mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 06:13:36 -07:00
Fix future continuations to use correct contexts
This commit is contained in:
parent
0262faa915
commit
674809b1d8
6 changed files with 14 additions and 34 deletions
|
@ -40,6 +40,9 @@ namespace BitTorrent
|
|||
{
|
||||
class TorrentContentHandler : public QObject, public AbstractFileStorage
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(TorrentContentHandler)
|
||||
|
||||
public:
|
||||
using QObject::QObject;
|
||||
|
||||
|
|
|
@ -401,17 +401,13 @@ void PeerListWidget::saveSettings() const
|
|||
Preferences::instance()->setPeerListState(header()->saveState());
|
||||
}
|
||||
|
||||
void PeerListWidget::loadPeers(const BitTorrent::Torrent *torrent)
|
||||
void PeerListWidget::loadPeers(BitTorrent::Torrent *torrent)
|
||||
{
|
||||
if (!torrent)
|
||||
return;
|
||||
|
||||
using TorrentPtr = QPointer<const BitTorrent::Torrent>;
|
||||
torrent->fetchPeerInfo().then(this, [this, torrent = TorrentPtr(torrent)](const QList<BitTorrent::PeerInfo> &peers)
|
||||
torrent->fetchPeerInfo().then(torrent, [this, torrent](const QList<BitTorrent::PeerInfo> &peers)
|
||||
{
|
||||
if (torrent != m_properties->getCurrentTorrent())
|
||||
return;
|
||||
|
||||
// Remove I2P peers since they will be completely reloaded.
|
||||
for (const QStandardItem *item : asConst(m_I2PPeerItems))
|
||||
m_listModel->removeRow(item->row());
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
explicit PeerListWidget(PropertiesWidget *parent);
|
||||
~PeerListWidget() override;
|
||||
|
||||
void loadPeers(const BitTorrent::Torrent *torrent);
|
||||
void loadPeers(BitTorrent::Torrent *torrent);
|
||||
void updatePeerHostNameResolutionState();
|
||||
void updatePeerCountryResolutionState();
|
||||
void clear();
|
||||
|
|
|
@ -479,10 +479,8 @@ void PropertiesWidget::loadDynamicData()
|
|||
// Pieces availability
|
||||
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(m_torrent, [this](const QList<int> &pieceAvailability)
|
||||
{
|
||||
if (torrent == m_torrent)
|
||||
m_piecesAvailability->setAvailability(pieceAvailability);
|
||||
});
|
||||
|
||||
|
@ -497,7 +495,7 @@ 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)
|
||||
m_torrent->fetchDownloadingPieces().then(m_torrent, [this](const QBitArray &downloadingPieces)
|
||||
{
|
||||
m_downloadedPieces->setProgress(m_torrent->pieces(), downloadingPieces);
|
||||
});
|
||||
|
@ -524,12 +522,8 @@ void PropertiesWidget::loadUrlSeeds()
|
|||
if (!m_torrent)
|
||||
return;
|
||||
|
||||
using TorrentPtr = QPointer<BitTorrent::Torrent>;
|
||||
m_torrent->fetchURLSeeds().then(this, [this, torrent = TorrentPtr(m_torrent)](const QList<QUrl> &urlSeeds)
|
||||
m_torrent->fetchURLSeeds().then(m_torrent, [this](const QList<QUrl> &urlSeeds)
|
||||
{
|
||||
if (torrent != m_torrent)
|
||||
return;
|
||||
|
||||
m_ui->listWebSeeds->clear();
|
||||
qDebug("Loading web seeds");
|
||||
// Add url seeds
|
||||
|
|
|
@ -219,20 +219,11 @@ void TorrentContentModel::updateFilesAvailability()
|
|||
{
|
||||
Q_ASSERT(m_contentHandler && m_contentHandler->hasMetadata());
|
||||
|
||||
using HandlerPtr = QPointer<BitTorrent::TorrentContentHandler>;
|
||||
m_contentHandler->fetchAvailableFileFractions().then(this
|
||||
, [this, handler = HandlerPtr(m_contentHandler)](const QList<qreal> &availableFileFractions)
|
||||
m_contentHandler->fetchAvailableFileFractions().then(m_contentHandler
|
||||
, [this](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]]
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -309,12 +309,8 @@ void TrackerListModel::populate()
|
|||
m_items->emplace_back(std::make_shared<Item>(u"** [PeX] **", privateTorrentMessage));
|
||||
m_items->emplace_back(std::make_shared<Item>(u"** [LSD] **", privateTorrentMessage));
|
||||
|
||||
using TorrentPtr = QPointer<const BitTorrent::Torrent>;
|
||||
m_torrent->fetchPeerInfo().then(this, [this, torrent = TorrentPtr(m_torrent)](const QList<BitTorrent::PeerInfo> &peers)
|
||||
m_torrent->fetchPeerInfo().then(m_torrent, [this](const QList<BitTorrent::PeerInfo> &peers)
|
||||
{
|
||||
if (torrent != m_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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue