mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-29 16:04:21 +00:00
- Improved updateDlList code
- Added some ASSERTS
This commit is contained in:
parent
c19937cf98
commit
6951619c04
@ -164,7 +164,7 @@ void FinishedTorrents::on_actionSet_upload_limit_triggered(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FinishedTorrents::updateFinishedList(){
|
void FinishedTorrents::updateFinishedList(){
|
||||||
// qDebug("Updating finished list");
|
Q_ASSERT((GUI*)parent->getCurrentTabIndex() == 1);
|
||||||
QString hash;
|
QString hash;
|
||||||
foreach(hash, finishedSHAs){
|
foreach(hash, finishedSHAs){
|
||||||
torrent_handle h = BTSession->getTorrentHandle(hash);
|
torrent_handle h = BTSession->getTorrentHandle(hash);
|
||||||
|
25
src/GUI.cpp
25
src/GUI.cpp
@ -565,7 +565,7 @@ void GUI::updateDlList(bool force){
|
|||||||
finishedTorrentTab->updateFinishedList();
|
finishedTorrentTab->updateFinishedList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// qDebug("Updating download list");
|
Q_ASSERT(tabs->currentIndex() == 0);
|
||||||
LCD_UpSpeed->display(tmp); // UP LCD
|
LCD_UpSpeed->display(tmp); // UP LCD
|
||||||
LCD_DownSpeed->display(tmp2); // DL LCD
|
LCD_DownSpeed->display(tmp2); // DL LCD
|
||||||
// browse handles
|
// browse handles
|
||||||
@ -577,7 +577,15 @@ void GUI::updateDlList(bool force){
|
|||||||
try{
|
try{
|
||||||
torrent_status torrentStatus = h.status();
|
torrent_status torrentStatus = h.status();
|
||||||
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
|
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
|
||||||
|
// If this is a finished torrent, no need to refresh it here
|
||||||
|
if(finishedSHAs.indexOf(fileHash) != -1) continue;
|
||||||
int row = getRowFromHash(fileHash);
|
int row = getRowFromHash(fileHash);
|
||||||
|
if(row == -1){
|
||||||
|
qDebug("Info: Could not find filename in download list, adding it...");
|
||||||
|
restoreInDownloadList(h);
|
||||||
|
row = getRowFromHash(fileHash);
|
||||||
|
}
|
||||||
|
Q_ASSERT(row != -1);
|
||||||
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(fileHash) != -1){
|
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(fileHash) != -1){
|
||||||
// Pause torrent if it finished checking and it is was supposed to be paused.
|
// Pause torrent if it finished checking and it is was supposed to be paused.
|
||||||
// This is a trick to see the progress of the pause torrents on startup
|
// This is a trick to see the progress of the pause torrents on startup
|
||||||
@ -595,21 +603,15 @@ void GUI::updateDlList(bool force){
|
|||||||
BTSession->setTorrentFinishedChecking(fileHash);
|
BTSession->setTorrentFinishedChecking(fileHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
row = getRowFromHash(fileHash); // List may have been sorted in the meantime
|
// No need to update a paused torrent
|
||||||
if(h.is_paused()) continue;
|
if(h.is_paused()) continue;
|
||||||
if(finishedSHAs.indexOf(fileHash) != -1) continue;
|
|
||||||
if(row == -1){
|
|
||||||
qDebug("Info: Could not find filename in download list, adding it...");
|
|
||||||
restoreInDownloadList(h);
|
|
||||||
row = getRowFromHash(fileHash);
|
|
||||||
}
|
|
||||||
// Parse download state
|
// Parse download state
|
||||||
torrent_info ti = h.get_torrent_info();
|
torrent_info ti = h.get_torrent_info();
|
||||||
// Setting download state
|
// Setting download state
|
||||||
switch(torrentStatus.state){
|
switch(torrentStatus.state){
|
||||||
case torrent_status::finished:
|
case torrent_status::finished:
|
||||||
case torrent_status::seeding:
|
case torrent_status::seeding:
|
||||||
qDebug("Warning: this shouldn't happen, no finished torrents in download tab, moving it");
|
qDebug("Not good: no finished torrents in download tab, moving it");
|
||||||
finishedTorrent(h);
|
finishedTorrent(h);
|
||||||
continue;
|
continue;
|
||||||
case torrent_status::checking_files:
|
case torrent_status::checking_files:
|
||||||
@ -659,7 +661,10 @@ void GUI::updateDlList(bool force){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// qDebug("Updated Download list");
|
}
|
||||||
|
|
||||||
|
unsigned int GUI::getCurrentTabIndex() const{
|
||||||
|
return tabs->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::restoreInDownloadList(torrent_handle h){
|
void GUI::restoreInDownloadList(torrent_handle h){
|
||||||
|
@ -187,6 +187,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
~GUI();
|
~GUI();
|
||||||
// Methods
|
// Methods
|
||||||
int getRowFromHash(QString hash) const;
|
int getRowFromHash(QString hash) const;
|
||||||
|
unsigned int getCurrentTabIndex() const;
|
||||||
QPoint screenCenter();
|
QPoint screenCenter();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user