From ca8f72c7bc02c085e4cadf979a532432e3a20cb3 Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Fri, 28 Dec 2007 05:00:56 +0000 Subject: [PATCH] fix timing bug (only the millisecond part of the timestamp was used) now the update intervals will actually work. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=753663 --- datacontainer.cpp | 16 ++++------------ datacontainer_p.h | 5 ++--- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/datacontainer.cpp b/datacontainer.cpp index 6b75114a9..86cce63b5 100644 --- a/datacontainer.cpp +++ b/datacontainer.cpp @@ -53,7 +53,7 @@ void DataContainer::setData(const QString& key, const QVariant& value) } d->dirty = true; - d->updateTs = QTime::currentTime().msec(); + d->updateTs.start(); } void DataContainer::clearData() @@ -82,17 +82,9 @@ void DataContainer::checkForUpdate() 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; + //FIXME: we still assume it's been <24h + //and ignore possible daylight savings changes + return d->updateTs.elapsed(); } bool DataContainer::hasUpdates() const diff --git a/datacontainer_p.h b/datacontainer_p.h index 22c75f3c3..64d8df775 100644 --- a/datacontainer_p.h +++ b/datacontainer_p.h @@ -32,8 +32,7 @@ class DataContainer::Private { public: Private() - : updateTs(0), - dirty(false) + : dirty(false) {} QObject* signalRelay(const DataContainer* dc, QObject *visualization, @@ -42,7 +41,7 @@ public: DataEngine::Data data; QMap relayObjects; QMap relays; - int updateTs; + QTime updateTs; bool dirty : 1; };