From 384f3b23ee5a8fb473d8dc34596a62007b60230d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 27 Dec 2008 09:10:07 +0000 Subject: [PATCH] - Made seed detection a bit safer (do not use progress) --- src/eventmanager.cpp | 4 ++-- src/qtorrenthandle.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 1d564b1f9..e8533ee1a 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -78,12 +78,12 @@ void EventManager::modifiedTorrent(QTorrentHandle h) } event["name"] = QVariant(h.name()); event["size"] = QVariant((qlonglong)h.actual_size()); - if(h.progress() < 1.) { + if(!h.is_seed()) { event["progress"] = QVariant(h.progress()); event["dlspeed"] = QVariant(h.download_payload_rate()); } event["upspeed"] = QVariant(h.upload_payload_rate()); - event["seed"] = QVariant(h.progress() == 1.); + event["seed"] = QVariant(h.is_seed()); event["hash"] = QVariant(hash); event_list[hash] = event; } diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 42eb6bc02..b3044105c 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -285,7 +285,10 @@ bool QTorrentHandle::is_seed() const { Q_ASSERT(h.is_valid()); // Affected by bug http://code.rasterbar.com/libtorrent/ticket/402 //return h.is_seed(); - return (progress() == 1.); + // May suffer from approximation problems + //return (progress() == 1.); + // This looks safe + return (state() == torrent_status::finished || state() == torrent_status::seeding); } bool QTorrentHandle::is_auto_managed() const {