Summary: | download age is not displayed correctly with kde32 cvs | ||
---|---|---|---|
Product: | [Applications] kmldonkey | Reporter: | marco puszina <marco> |
Component: | general | Assignee: | Petter Stokke <ummo> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 0.9.1 | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | screenshot |
Description
marco puszina
2004-01-11 05:02:26 UTC
Created attachment 4087 [details]
screenshot
I'm getting the same thing here; seems like a recent kdelibs development, as it wasn't happening with CVS HEAD from a week or so ago and there's not been any changes in the relevant KMLDonkey code since then (or in mldonkey, for that matter). Will investigate as soon as time permits. Subject: kdeextragear-2/kmldonkey/libkmldonkey CVS commit by pstokke: Worked around an mldonkey core bug. It seems that for time values over 0x40000000 (ie. last Saturday afternoon) the core starts sending out negative time values, which can be corrected by adding 0x80000000. This patch uses 0x7FFFFFFF just to avoid any signedness problems that might crop up (I'm paranoid about bad compilers), so the time will actually be one second off. You're welcome to sue. CCMAIL: 72355-done@bugs.kde.org M +9 -5 fileinfo.cpp 1.5 M +7 -4 fileinfo.h 1.4 --- kdeextragear-2/kmldonkey/libkmldonkey/fileinfo.cpp #1.4:1.5 @@ -101,7 +101,11 @@ void FileInfo::updateFileInfo(DonkeyMess j = msg->readInt16(); chunks_age.clear(); - for (i=0; i<j; i++) - chunks_age.append(msg->readFloat()); - age = msg->readFloat(); + for (i=0; i<j; i++) { + time_t a = (int)msg->readFloat(); + if (a < 0) a = 0x7fffffff + a; + chunks_age.append(a); + } + age = (time_t)msg->readFloat(); + if (age < 0) age = 0x7fffffff + age; format = msg->readInt8(); switch (format) { @@ -228,10 +232,10 @@ const double FileInfo::fileSpeed() const } -const QValueList<double>& FileInfo::fileChunksAge() const +const QValueList<time_t>& FileInfo::fileChunksAge() const { return chunks_age; } -const double FileInfo::fileAge() const +const time_t FileInfo::fileAge() const { return age; --- kdeextragear-2/kmldonkey/libkmldonkey/fileinfo.h #1.3:1.4 @@ -30,4 +30,7 @@ #include <qcstring.h> +#include <sys/types.h> +#include <time.h> + #include "donkeytypes.h" @@ -88,7 +91,7 @@ class FileInfo const double fileSpeed() const; //! The age of individual chunks. - const QValueList<double>& fileChunksAge() const; + const QValueList<time_t>& fileChunksAge() const; //! The time the download was started (seconds since Epoch). - const double fileAge() const; + const time_t fileAge() const; //! The file format. const int fileFormat() const; @@ -127,6 +130,6 @@ private: QMap<int,QByteArray> availability; double speed; - QValueList<double> chunks_age; - double age; + QValueList<time_t> chunks_age; + time_t age; int format; QString formatinfo; Instead of testing for negative, then conditionally adding 0x7FFFFFFF, you can also just 'and' unconditionally with 0x7FFFFFFF. This will also prevent the one-second-off error... ;-) |