From 9e49778380c056b1ce7f30dbd774c545bff030c5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jun 2016 14:27:48 -0700 Subject: Fix/adapt the uses of {to,set,from}Time_t in the qtbase source code Move those to the equivalent {to,set,from}SecsSinceEpoch(), except for the cases that did QDateTime::currentDateTime{,Utc}().toTime_t. Those are best implemented with QDateTime::currentSecsSinceEpoch(). Change-Id: Ib57b52598e2f452985e9fffd145a366c92cfda20 Reviewed-by: Edward Welbourne --- examples/network/torrent/connectionmanager.cpp | 2 +- examples/network/torrent/metainfo.cpp | 2 +- examples/network/torrent/torrentclient.cpp | 4 ++-- examples/widgets/animation/stickman/lifecycle.cpp | 2 +- examples/widgets/painting/composition/composition.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/network/torrent/connectionmanager.cpp b/examples/network/torrent/connectionmanager.cpp index 99462fb489..acab59b0e3 100644 --- a/examples/network/torrent/connectionmanager.cpp +++ b/examples/network/torrent/connectionmanager.cpp @@ -86,7 +86,7 @@ QByteArray ConnectionManager::clientId() const { if (id.isEmpty()) { // Generate peer id - int startupTime = int(QDateTime::currentDateTime().toTime_t()); + qint64 startupTime = QDateTime::currentSecsSinceEpoch(); id += QString::asprintf("-QT%04x-", (QT_VERSION % 0xffff00) >> 8).toLatin1(); id += QByteArray::number(startupTime, 10); diff --git a/examples/network/torrent/metainfo.cpp b/examples/network/torrent/metainfo.cpp index e3718999b8..565533e2f9 100644 --- a/examples/network/torrent/metainfo.cpp +++ b/examples/network/torrent/metainfo.cpp @@ -141,7 +141,7 @@ bool MetaInfo::parse(const QByteArray &data) } if (dict.contains("creation date")) - metaInfoCreationDate.setTime_t(dict.value("creation date").toInt()); + metaInfoCreationDate.setSecsSinceEpoch(dict.value("creation date").toInt()); if (dict.contains("comment")) metaInfoComment = QString::fromUtf8(dict.value("comment").toByteArray()); if (dict.contains("created by")) diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp index 6b184be39c..ba87924ff9 100644 --- a/examples/network/torrent/torrentclient.cpp +++ b/examples/network/torrent/torrentclient.cpp @@ -703,7 +703,7 @@ void TorrentClient::connectToPeers() // Pick a random peer from the list of weighed peers. TorrentPeer *peer = weighedPeers.takeAt(qrand() % weighedPeers.size()); weighedPeers.removeAll(peer); - peer->connectStart = QDateTime::currentDateTime().toTime_t(); + peer->connectStart = QDateTime::currentSecsSinceEpoch(); peer->lastVisited = peer->connectStart; // Connect to the peer. @@ -717,7 +717,7 @@ QList TorrentClient::weighedFreePeers() const QList weighedPeers; // Generate a list of peers that we want to connect to. - uint now = QDateTime::currentDateTime().toTime_t(); + qint64 now = QDateTime::currentSecsSinceEpoch(); QList freePeers; QMap connectionsPerPeer; foreach (TorrentPeer *peer, d->peers) { diff --git a/examples/widgets/animation/stickman/lifecycle.cpp b/examples/widgets/animation/stickman/lifecycle.cpp index fcb351cf36..0ece4f3932 100644 --- a/examples/widgets/animation/stickman/lifecycle.cpp +++ b/examples/widgets/animation/stickman/lifecycle.cpp @@ -91,7 +91,7 @@ public: : QEventTransition(this, QEvent::Timer) { setTargetState(target); - qsrand((uint)QDateTime::currentDateTime().toTime_t()); + qsrand((uint)QDateTime::currentSecsSinceEpoch()); startTimer(1000); } diff --git a/examples/widgets/painting/composition/composition.cpp b/examples/widgets/painting/composition/composition.cpp index 1c2802f860..d5d674fd83 100644 --- a/examples/widgets/painting/composition/composition.cpp +++ b/examples/widgets/painting/composition/composition.cpp @@ -290,7 +290,7 @@ void CompositionRenderer::updateCirclePos() if (m_current_object != NoObject) return; QDateTime dt = QDateTime::currentDateTime(); - qreal t = (dt.toTime_t() * 1000 + dt.time().msec()) / 1000.0; + qreal t = dt.toMSecsSinceEpoch() / 1000.0; qreal x = width() / qreal(2) + (qCos(t*8/11) + qSin(-t)) * width() / qreal(4); qreal y = height() / qreal(2) + (qSin(t*6/7) + qCos(t * qreal(1.5))) * height() / qreal(4); -- cgit v1.2.3