From 34aa0106620836d360f2deebaa8d88ef52ba1a7e Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 8 Apr 2013 00:22:18 +0200 Subject: [PATCH 1/1] Fix lag display Not sure what I was thinking in d3ce95c, but that commit a) didn't fix compiling with Qt < 4.7 b) confused local time and UTC, which c) completely bugged lag display. Should be working now. --- src/common/protocols/legacy/legacypeer.cpp | 4 ++-- src/common/remotepeer.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/common/protocols/legacy/legacypeer.cpp b/src/common/protocols/legacy/legacypeer.cpp index d0000473..0f9c61e0 100644 --- a/src/common/protocols/legacy/legacypeer.cpp +++ b/src/common/protocols/legacy/legacypeer.cpp @@ -208,7 +208,7 @@ void LegacyPeer::handlePackedFunc(const QVariant &packedFunc) } // The legacy protocol would only send a QTime, no QDateTime // so we assume it's sent today, which works in exactly the same cases as it did in the old implementation - QDateTime dateTime = QDateTime::currentDateTimeUtc(); + QDateTime dateTime = QDateTime::currentDateTime().toUTC(); dateTime.setTime(params[0].toTime()); handle(Protocol::HeartBeat(dateTime)); break; @@ -220,7 +220,7 @@ void LegacyPeer::handlePackedFunc(const QVariant &packedFunc) } // The legacy protocol would only send a QTime, no QDateTime // so we assume it's sent today, which works in exactly the same cases as it did in the old implementation - QDateTime dateTime = QDateTime::currentDateTimeUtc(); + QDateTime dateTime = QDateTime::currentDateTime().toUTC(); dateTime.setTime(params[0].toTime()); handle(Protocol::HeartBeatReply(dateTime)); break; diff --git a/src/common/remotepeer.cpp b/src/common/remotepeer.cpp index f8deabfa..44033bd6 100644 --- a/src/common/remotepeer.cpp +++ b/src/common/remotepeer.cpp @@ -166,11 +166,7 @@ void RemotePeer::handle(const HeartBeat &heartBeat) void RemotePeer::handle(const HeartBeatReply &heartBeatReply) { _heartBeatCount = 0; -#if QT_VERSION < 0x040700 - emit lagUpdated(heartBeatReply.timestamp().time().msecsTo(QTime::currentTime()) / 2); -#else - emit lagUpdated(heartBeatReply.timestamp().msecsTo(QDateTime::currentDateTime()) / 2); -#endif + emit lagUpdated(heartBeatReply.timestamp().msecsTo(QDateTime::currentDateTime().toUTC()) / 2); } @@ -189,8 +185,6 @@ void RemotePeer::sendHeartBeat() emit lagUpdated(_lag); } - dispatch(HeartBeat(QDateTime::currentDateTime())); + dispatch(HeartBeat(QDateTime::currentDateTime().toUTC())); ++_heartBeatCount; } - - -- 2.20.1