From 341a88c2efa4f9a1bddcaa0dbabe44584b317b47 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 27 Sep 2011 17:11:50 +0300 Subject: [PATCH] BUGFIX: Fix ratio calculation (use all_time_download) --- Changelog | 1 + src/qtlibtorrent/qbtsession.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index d56f9cf91..20522041b 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ - BUGFIX: Fix execution log lines selection and copying - BUGFIX: Reduce CPU usage when running Web UI - BUGFIX: Save RSS items to disk regularly for safety + - BUGFIX: Fix ratio calculation (use all_time_download) - COSMETIC: Display speed at the beginning of the Window title - COSMETIC: Several cosmetic fixes to the Web UI - OTHER: Display libraries versions in about dialog (sledgehammer999) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index d054198b6..e09038065 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1588,14 +1588,15 @@ qreal QBtSession::getRealRatio(const QString &hash) const{ if(!h.is_valid()) { return 0.; } - Q_ASSERT(h.total_done() >= 0); - Q_ASSERT(h.all_time_upload() >= 0); - if(h.total_done() == 0) { - if(h.all_time_upload() == 0) + const libtorrent::size_type all_time_download = h.all_time_download(); + const libtorrent::size_type all_time_upload = h.all_time_upload(); + + if(all_time_download == 0) { + if(all_time_upload == 0) return 0; return MAX_RATIO+1; } - qreal ratio = (float)h.all_time_upload()/(float)h.total_done(); + qreal ratio = all_time_upload / (float) all_time_download; Q_ASSERT(ratio >= 0.); if(ratio > MAX_RATIO) ratio = MAX_RATIO;