From 7921adbcf9a55f5df46c3b900051b79fa5f71927 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 28 Aug 2007 19:22:05 +0000 Subject: [PATCH] - Cleaned torrent progress asserts --- src/FinishedTorrents.cpp | 2 -- src/downloadingTorrents.cpp | 5 ----- src/qtorrenthandle.cpp | 4 +++- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index e05a5f855..1897a33ff 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -209,7 +209,6 @@ void FinishedTorrents::updateFinishedList(){ } Q_ASSERT(row != -1); if(h.is_paused()) continue; - Q_ASSERT(h.progress() <= 1. && h.progress() >= 0.); 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! qDebug("Info: a torrent was moved from finished to download tab"); @@ -223,7 +222,6 @@ void FinishedTorrents::updateFinishedList(){ finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/time.png"))), Qt::DecorationRole); setRowColor(row, QString::fromUtf8("grey")); } - Q_ASSERT(h.progress() <= 1. && h.progress() >= 0.); finishedListModel->setData(finishedListModel->index(row, F_PROGRESS), QVariant((double)h.progress())); continue; } diff --git a/src/downloadingTorrents.cpp b/src/downloadingTorrents.cpp index ec69885e2..14c166795 100644 --- a/src/downloadingTorrents.cpp +++ b/src/downloadingTorrents.cpp @@ -137,7 +137,6 @@ void DownloadingTorrents::pauseTorrent(QString hash) { DLListModel->setData(DLListModel->index(row, NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0"))); QTorrentHandle h = BTSession->getTorrentHandle(hash); - Q_ASSERT(h.progress() <= 1. && h.progress() >= 0.); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); setRowColor(row, QString::fromUtf8("red")); } @@ -389,7 +388,6 @@ void DownloadingTorrents::updateDlList() { DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/time.png"))), Qt::DecorationRole); setRowColor(row, QString::fromUtf8("grey")); } - Q_ASSERT(h.progress() <= 1. && h.progress() >= 0.); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); break; case torrent_status::connecting_to_tracker: @@ -403,7 +401,6 @@ void DownloadingTorrents::updateDlList() { DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole); setRowColor(row, QString::fromUtf8("grey")); } - Q_ASSERT(h.progress() <= 1. && h.progress() >= 0.); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)h.download_payload_rate())); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)h.upload_payload_rate())); @@ -419,7 +416,6 @@ void DownloadingTorrents::updateDlList() { DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); setRowColor(row, QString::fromUtf8("black")); } - Q_ASSERT(h.progress() <= 1. && h.progress() >= 0.); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)h.download_payload_rate())); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)h.upload_payload_rate())); @@ -655,7 +651,6 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) { Q_ASSERT(row != -1); QTorrentHandle h = BTSession->getTorrentHandle(hash); DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size())); - Q_ASSERT(h.progress() <= 1.); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); } diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 5e8fdbb2a..b8272f2fa 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -55,7 +55,9 @@ QString QTorrentHandle::name() const { float QTorrentHandle::progress() const { Q_ASSERT(h.is_valid()); - return h.status().progress; + float progress = h.status().progress; + Q_ASSERT(progress >= 0. && progress <= 1.); + return progress; } QString QTorrentHandle::current_tracker() const {