Browse Source

Merge pull request #2140 from sorokin/fix-torrent-removal

Fix torrent removal. Closes #2132
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
6d64f2430c
  1. 2
      src/qtlibtorrent/qbtsession.cpp
  2. 1
      src/qtlibtorrent/qbtsession.h
  3. 19
      src/qtlibtorrent/torrentmodel.cpp
  4. 1
      src/qtlibtorrent/torrentmodel.h
  5. 7
      src/qtlibtorrent/torrentspeedmonitor.cpp
  6. 1
      src/qtlibtorrent/torrentspeedmonitor.h

2
src/qtlibtorrent/qbtsession.cpp

@ -821,8 +821,6 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) { @@ -821,8 +821,6 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) {
else
addConsoleMessage(tr("'%1' was removed from transfer list.", "'xxx.avi' was removed...").arg(fileName));
qDebug("Torrent deleted.");
emit deletedTorrent(hash);
qDebug("Deleted signal emitted.");
}
void QBtSession::pauseAllTorrents() {

1
src/qtlibtorrent/qbtsession.h

@ -272,7 +272,6 @@ private slots: @@ -272,7 +272,6 @@ private slots:
signals:
void addedTorrent(const QTorrentHandle& h);
void deletedTorrent(const QString &hash);
void torrentAboutToBeRemoved(const QTorrentHandle &h);
void pausedTorrent(const QTorrentHandle& h);
void resumedTorrent(const QTorrentHandle& h);

19
src/qtlibtorrent/torrentmodel.cpp

@ -331,7 +331,6 @@ void TorrentModel::populate() { @@ -331,7 +331,6 @@ void TorrentModel::populate() {
// Listen for torrent changes
connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), SLOT(addTorrent(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(handleTorrentAboutToBeRemoved(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(deletedTorrent(QString)), SLOT(removeTorrent(QString)));
connect(QBtSession::instance(), SIGNAL(finishedTorrent(QTorrentHandle)), SLOT(handleFinishedTorrent(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(metadataReceived(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(resumedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
@ -440,18 +439,6 @@ void TorrentModel::addTorrent(const QTorrentHandle &h) @@ -440,18 +439,6 @@ void TorrentModel::addTorrent(const QTorrentHandle &h)
}
}
void TorrentModel::removeTorrent(const QString &hash)
{
const int row = torrentRow(hash);
qDebug() << Q_FUNC_INFO << hash << row;
if (row >= 0) {
beginRemoveTorrent(row);
delete m_torrents[row];
m_torrents.removeAt(row);
endRemoveTorrent();
}
}
void TorrentModel::beginInsertTorrent(int row)
{
beginInsertRows(QModelIndex(), row, row);
@ -578,8 +565,14 @@ QString TorrentModel::torrentHash(int row) const @@ -578,8 +565,14 @@ QString TorrentModel::torrentHash(int row) const
void TorrentModel::handleTorrentAboutToBeRemoved(const QTorrentHandle &h)
{
const int row = torrentRow(h.hash());
qDebug() << Q_FUNC_INFO << row;
if (row >= 0) {
emit torrentAboutToBeRemoved(m_torrents.at(row));
beginRemoveTorrent(row);
delete m_torrents[row];
m_torrents.removeAt(row);
endRemoveTorrent();
}
}

1
src/qtlibtorrent/torrentmodel.h

@ -105,7 +105,6 @@ signals: @@ -105,7 +105,6 @@ signals:
private slots:
void addTorrent(const QTorrentHandle& h);
void removeTorrent(const QString &hash);
void handleTorrentUpdate(const QTorrentHandle &h);
void handleFinishedTorrent(const QTorrentHandle& h);
void notifyTorrentChanged(int row);

7
src/qtlibtorrent/torrentspeedmonitor.cpp

@ -117,7 +117,7 @@ private: @@ -117,7 +117,7 @@ private:
TorrentSpeedMonitor::TorrentSpeedMonitor(QBtSession* session)
: m_session(session)
{
connect(m_session, SIGNAL(deletedTorrent(QString)), SLOT(removeSamples(QString)));
connect(m_session, SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(removeSamples(QTorrentHandle)));
connect(m_session, SIGNAL(pausedTorrent(QTorrentHandle)), SLOT(removeSamples(QTorrentHandle)));
connect(m_session, SIGNAL(statsReceived(libtorrent::stats_alert)), SLOT(statsReceived(libtorrent::stats_alert)));
}
@ -143,11 +143,6 @@ Sample<qreal> SpeedSample::average() const @@ -143,11 +143,6 @@ Sample<qreal> SpeedSample::average() const
return Sample<qreal>(m_sum) * (1. / m_speedSamples.size());
}
void TorrentSpeedMonitor::removeSamples(const QString &hash)
{
m_samples.remove(hash);
}
void TorrentSpeedMonitor::removeSamples(const QTorrentHandle& h) {
try {
m_samples.remove(h.hash());

1
src/qtlibtorrent/torrentspeedmonitor.h

@ -52,7 +52,6 @@ public: @@ -52,7 +52,6 @@ public:
private slots:
void statsReceived(const libtorrent::stats_alert& stats);
void removeSamples(const QString& hash);
void removeSamples(const QTorrentHandle& h);
private:

Loading…
Cancel
Save