I have found the error. In src/FinishedTorrents.cpp, line 262 (for 1.2.0beta2)
is a comparison "h.progress() < 1.". The progress is calculated as a division
of two numbers which due to float inaccuracies is sometimes not exactly 1, so
the comparison fails sometimes even if the file is finished.

I've attached a patch working around that problem, the solution should be
obvious. Additionally, line 268 also seems wrong, the patch should be
self-explanatory.
diff -ur qbittorrent-1.2.0beta2-orig/src/FinishedTorrents.cpp qbittorrent-1.2.0beta2/src/FinishedTorrents.cpp
--- qbittorrent-1.2.0beta2-orig/src/FinishedTorrents.cpp	2008-07-27 17:51:14.000000000 +0200
+++ qbittorrent-1.2.0beta2/src/FinishedTorrents.cpp	2008-08-15 17:32:19.007286759 +0200
@@ -265,7 +265,7 @@
       if (reponse == QMessageBox::Yes) {
         qDebug("Info: a torrent was moved from finished to download tab");
         deleteTorrent(hash);
-        BTSession->setFinishedTorrent(hash);
+        BTSession->setUnfinishedTorrent(hash);
         emit torrentMovedFromFinishedList(hash);
       }
       else if (reponse == QMessageBox::No) {
diff -ur qbittorrent-1.2.0beta2-orig/src/qtorrenthandle.cpp qbittorrent-1.2.0beta2/src/qtorrenthandle.cpp
--- qbittorrent-1.2.0beta2-orig/src/qtorrenthandle.cpp	2008-07-16 23:54:01.000000000 +0200
+++ qbittorrent-1.2.0beta2/src/qtorrenthandle.cpp	2008-08-15 17:30:36.994620098 +0200
@@ -57,6 +57,8 @@
   Q_ASSERT(h.is_valid());
   if(!h.status().total_wanted)
     return 0.;
+  if (h.status().total_wanted_done == h.status().total_wanted)
+    return 1.;
   float progress = (float)h.status().total_wanted_done/(float)h.status().total_wanted;
   Q_ASSERT(progress >= 0. && progress <= 1.);
   return progress;

Reply via email to