- Fixed a bug when deleting a torrent from finished list (just introduced)

This commit is contained in:
Christophe Dumez 2007-08-20 06:41:36 +00:00
parent c9925eddb6
commit a28160bcaa
3 changed files with 11 additions and 6 deletions

View File

@ -178,7 +178,7 @@ void FinishedTorrents::updateFinishedList(){
if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.progress() < 1.)) { if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.progress() < 1.)) {
// What are you doing here? go back to download tab! // What are you doing here? go back to download tab!
qDebug("Info: a torrent was moved from finished to download tab"); qDebug("Info: a torrent was moved from finished to download tab");
deleteFromFinishedList(hash); deleteFromFinishedList(hash, true);
BTSession->setFinishedTorrent(hash); BTSession->setFinishedTorrent(hash);
emit torrentMovedFromFinishedList(h); emit torrentMovedFromFinishedList(h);
continue; continue;
@ -200,14 +200,15 @@ int FinishedTorrents::getRowFromHash(QString hash) const{
} }
// Will move it to download tab // Will move it to download tab
void FinishedTorrents::deleteFromFinishedList(QString hash){ void FinishedTorrents::deleteFromFinishedList(QString hash, bool switchTab){
int row = getRowFromHash(hash); int row = getRowFromHash(hash);
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
finishedListModel->removeRow(row); finishedListModel->removeRow(row);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished");
--nbFinished; --nbFinished;
((GUI*)parent)->setTabText(1, tr("Finished") +" ("+QString::fromUtf8(misc::toString(nbFinished).c_str())+")"); ((GUI*)parent)->setTabText(1, tr("Finished") +" ("+QString::fromUtf8(misc::toString(nbFinished).c_str())+")");
BTSession->setUnfinishedTorrent(hash); if(switchTab)
BTSession->setUnfinishedTorrent(hash);
} }
QTreeView* FinishedTorrents::getFinishedList(){ QTreeView* FinishedTorrents::getFinishedList(){

View File

@ -53,7 +53,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
public slots: public slots:
void addFinishedTorrent(QString hash); void addFinishedTorrent(QString hash);
void updateFinishedList(); void updateFinishedList();
void deleteFromFinishedList(QString hash); void deleteFromFinishedList(QString hash, bool switchTab=false);
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void propertiesSelection(); void propertiesSelection();
void displayFinishedListMenu(const QPoint&); void displayFinishedListMenu(const QPoint&);

View File

@ -554,6 +554,10 @@ void GUI::updateDlList(bool force) {
QString hash; QString hash;
foreach(hash, unfinishedTorrents) { foreach(hash, unfinishedTorrents) {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(!h.is_valid()){
qDebug("We have an invalid handle for: %s", qPrintable(hash));
continue;
}
try{ try{
QString hash = h.hash(); QString hash = h.hash();
int row = getRowFromHash(hash); int row = getRowFromHash(hash);
@ -1027,7 +1031,7 @@ void GUI::on_actionDelete_Permanently_triggered() {
--nbTorrents; --nbTorrents;
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nbTorrents)+QString::fromUtf8(")")); tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nbTorrents)+QString::fromUtf8(")"));
} else { } else {
finishedTorrentTab->deleteFromFinishedList(hash); finishedTorrentTab->deleteFromFinishedList(hash, false);
} }
// Update info bar // Update info bar
setInfoBar(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName)); setInfoBar(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName));
@ -1102,7 +1106,7 @@ void GUI::on_actionDelete_triggered() {
--nbTorrents; --nbTorrents;
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nbTorrents)+QString::fromUtf8(")")); tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nbTorrents)+QString::fromUtf8(")"));
} else { } else {
finishedTorrentTab->deleteFromFinishedList(hash); finishedTorrentTab->deleteFromFinishedList(hash, false);
} }
// Update info bar // Update info bar
setInfoBar(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName)); setInfoBar(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName));