[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    [Panel-devel] [patch] datacontainer timestamp fix
From:       RĂ¼diger_Hacke <rudwardt () gmx ! de>
Date:       2007-09-23 21:42:51
Message-ID: 200709232343.03452.rudwardt () gmx ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

in Plasma::DataContainer you've got the following function:

int DataContainer::timeSinceLastUpdate() const
{
    int msec = QTime::currentTime().msec();
    if (msec < d->updateTs) {
        // we wrapped over midnight here, so return the current
        // msec's plus the number of msec left in the previous day.
        // 86400000 is the # of msec in a day
        //
        // yes, we assume we don't wrap more than one day here.
        return msec + (86400000 - d->updateTs);
    }
    return msec - d->updateTs;
}

This won't work because QTime.msec() only returns the millisecond fraction of 
the time (0-999). I fell for exactly the same thing, thus I spotted it.

See the attachment for one possibility to fix this.

kind regards,
Rudi

["fix_timestamp.diff" (text/x-diff)]

Index: datacontainer.cpp
===================================================================
--- datacontainer.cpp	(Revision 716055)
+++ datacontainer.cpp	(Arbeitskopie)
@@ -53,7 +53,7 @@
     }
 
     d->dirty = true;
-    d->updateTs = QTime::currentTime().msec();
+    d->updateTs = QTime().msecsTo(QTime::currentTime());
 }
 
 void DataContainer::clearData()
@@ -82,7 +82,7 @@
 
 int DataContainer::timeSinceLastUpdate() const
 {
-    int msec = QTime::currentTime().msec();
+    int msec = QTime().msecsTo(QTime::currentTime());
     if (msec < d->updateTs) {
         // we wrapped over midnight here, so return the current
         // msec's plus the number of msec left in the previous day.

["signature.asc" (application/pgp-signature)]

_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic