QDateTime::fromTime_t has been obsoleted in favour of QDateTime::fromSecsSinceEpoch, which is available from Qt 5.8+.
replace QDateTime::fromTime_t with QDateTime::fromSecsSinceEpoch #349
pull fanquake wants to merge 2 commits into bitcoin-core:master from fanquake:qt_drop_from_time_t changing 8 files +15 −11-
fanquake commented at 5:02 AM on May 31, 2021: member
-
hebasto commented at 8:02 AM on May 31, 2021: member
Concept ACK.
Interesting that there are no
[-Wdeprecated-declarations]warnings in the build log (Fedora 34 + Qt 5.15.2). -
in src/qt/guiutil.cpp:84 in 01ba23e48f outdated
80 | @@ -81,7 +81,7 @@ QString dateTimeStr(const QDateTime &date) 81 | 82 | QString dateTimeStr(qint64 nTime) 83 | { 84 | - return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); 85 | + return dateTimeStr(QDateTime::fromSecsSinceEpoch((qint32)nTime));
MarcoFalke commented at 8:11 AM on May 31, 2021:return dateTimeStr(QDateTime::fromSecsSinceEpoch(nTime));in src/qt/transactiontablemodel.cpp:613 in 01ba23e48f outdated
609 | @@ -610,7 +610,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const 610 | case TypeRole: 611 | return rec->type; 612 | case DateRole: 613 | - return QDateTime::fromTime_t(static_cast<uint>(rec->time)); 614 | + return QDateTime::fromSecsSinceEpoch(static_cast<uint>(rec->time));
MarcoFalke commented at 8:11 AM on May 31, 2021:return QDateTime::fromSecsSinceEpoch(qint64{rec->time});
fanquake commented at 5:17 AM on June 7, 2021:Reverted per #349 (review).
in src/qt/transactiontablemodel.cpp:633 in 01ba23e48f outdated
629 | @@ -630,7 +630,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const 630 | case TxPlainTextRole: 631 | { 632 | QString details; 633 | - QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time)); 634 | + QDateTime date = QDateTime::fromSecsSinceEpoch(static_cast<uint>(rec->time));
MarcoFalke commented at 8:11 AM on May 31, 2021:same
MarcoFalke commented at 8:12 AM on May 31, 2021: contributorYou are passing the wrong type. Otherwise Concept ACK
in src/qt/transactionfilterproxy.cpp:15 in 01ba23e48f outdated
9 | @@ -10,9 +10,9 @@ 10 | #include <cstdlib> 11 | 12 | // Earliest date that can be represented (far in the past) 13 | -const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); 14 | +const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0); 15 | // Last date that can be represented (far in the future) 16 | -const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); 17 | +const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(0xFFFFFFFF);
hebasto commented at 8:19 AM on May 31, 2021:If @MarcoFalke's suggestions will be addressed, the max
qint64could be also fixed.
MarcoFalke commented at 6:06 AM on June 3, 2021:const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max());not sure if this compiles
hebasto commented at 9:20 AM on June 6, 2021:not sure if this compiles
It does.
Also the
<limits>header could be included:--- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -8,11 +8,12 @@ #include <qt/transactionrecord.h> #include <cstdlib> +#include <limits> // Earliest date that can be represented (far in the past) const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0); // Last date that can be represented (far in the future) -const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(0xFFFFFFFF); +const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max()); TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : QSortFilterProxyModel(parent),fanquake force-pushed on Jun 1, 2021promag commented at 8:37 PM on June 2, 2021: contributorConcept ACK. No longer scripted-diff.
fanquake renamed this:scripted-diff: replace QDateTime::fromTime_t with QDateTime::fromSecsSinceEpoch
replace QDateTime::fromTime_t with QDateTime::fromSecsSinceEpoch
on Jun 3, 2021MarcoFalke approvedMarcoFalke commented at 6:06 AM on June 3, 2021: contributorACK
in src/qt/transactiontablemodel.cpp:613 in ac577c573a outdated
609 | @@ -610,7 +610,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const 610 | case TypeRole: 611 | return rec->type; 612 | case DateRole: 613 | - return QDateTime::fromTime_t(static_cast<uint>(rec->time)); 614 | + return QDateTime::fromSecsSinceEpoch(qint64{rec->time});
hebasto commented at 9:35 AM on June 6, 2021:rec->timeis of typeqint64: https://github.com/bitcoin-core/gui/blob/e033ca13794699cf4744e71647db75c583a9a600/src/qt/transactionrecord.h#L116in src/qt/transactiontablemodel.cpp:633 in ac577c573a outdated
629 | @@ -630,7 +630,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const 630 | case TxPlainTextRole: 631 | { 632 | QString details; 633 | - QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time)); 634 | + QDateTime date = QDateTime::fromSecsSinceEpoch(qint64{rec->time});
hebasto commented at 9:36 AM on June 6, 2021:rec->timeis of typeqint64: https://github.com/bitcoin-core/gui/blob/e033ca13794699cf4744e71647db75c583a9a600/src/qt/transactionrecord.h#L116hebasto changes_requestedfanquake force-pushed on Jun 7, 2021fanquake force-pushed on Jun 7, 2021MarcoFalke commented at 5:40 AM on June 7, 2021: contributorcr ACK 4f5e9feb64400948223ae153b74eb41811f53cff
fanquake force-pushed on Jun 7, 2021fanquake commented at 6:37 AM on June 7, 2021: memberAdded one additional commit to replace
QDateTime::toTime_twithQDateTime::toSecsSinceEpoch.hebasto approvedhebasto commented at 12:24 PM on June 7, 2021: member~ACK bd533e785903af0ba04cb0511c907b98008b056c,~ (will look into CI failures)
$ git grep fromTime_t | wc -l 0 $ git grep toTime_t | wc -l 0Maybe update the OP to mention the second commit changes?
in src/qt/recentrequeststablemodel.cpp:237 in bd533e7859 outdated
233 | @@ -234,7 +234,7 @@ bool RecentRequestEntryLessThan::operator()(const RecentRequestEntry& left, cons 234 | switch(column) 235 | { 236 | case RecentRequestsTableModel::Date: 237 | - return pLeft->date.toTime_t() < pRight->date.toTime_t(); 238 | + return pLeft->date.toSecsSinceEpoch() < pRight->date.toSecsSinceEpoch();
Talkless commented at 6:38 PM on June 17, 2021:Out of scope, but I wonder why
bool QDateTime::operator<is not used directly, withouttoTimeT()/toSecsSinceEpoch()?in src/qt/transactionfilterproxy.cpp:16 in bd533e7859 outdated
13 | // Earliest date that can be represented (far in the past) 14 | -const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); 15 | +const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0); 16 | // Last date that can be represented (far in the future) 17 | -const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); 18 | +const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max());
Talkless commented at 6:38 PM on June 17, 2021:From Qt documentation [0]:
Note that there are possible values for secs that lie outside the valid range of QDateTime, both negative and positive. The behavior of this function is undefined for those values.
Anyone knows what are these "ouside" values, and is this
::max()OK here then?[0] https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
Talkless commented at 6:39 PM on June 17, 2021: noneConcept ACK
hebasto added the label Refactoring on Jun 28, 2021DrahtBot added the label Needs rebase on Aug 11, 2021fanquake force-pushed on Aug 15, 2021DrahtBot removed the label Needs rebase on Aug 15, 2021MarcoFalke commented at 10:49 AM on August 23, 2021: contributorcr ACK bfcde3e87231d90bdacd3a8154e2be16a52508c7
in src/qt/recentrequeststablemodel.h:30 in bfcde3e872 outdated
25 | @@ -26,9 +26,9 @@ class RecentRequestEntry 26 | 27 | SERIALIZE_METHODS(RecentRequestEntry, obj) { 28 | unsigned int date_timet;
MarcoFalke commented at 10:50 AM on August 23, 2021:unrelated: This is still the wrong type
fanquake commented at 1:45 AM on August 24, 2021:Changed the type here.
in src/qt/transactionfilterproxy.cpp:11 in bfcde3e872 outdated
7 | @@ -8,6 +8,7 @@ 8 | #include <qt/transactionrecord.h> 9 | 10 | #include <cstdlib> 11 | +#include <limits>
hebasto commented at 9:00 PM on August 23, 2021:This change is unrelated after the recent rebase and could be dropped.
fanquake commented at 1:26 AM on August 24, 2021:Replaced it with the headers that are actually used.
hebasto commented at 9:01 PM on August 23, 2021: memberApproach ACK bfcde3e87231d90bdacd3a8154e2be16a52508c7.
fanquake force-pushed on Aug 24, 2021fanquake force-pushed on Aug 24, 2021hebasto commented at 6:52 AM on August 24, 2021: member./serialize.h:676:6: error: member reference base type 'long long' is not a structure or union a.Unserialize(is); ~^~~~~~~~~~~~refactor: replace QDateTime::fromTime_t with QDateTime::fromSecsSinceEpoch 27257b39bfrefactor: replace QDateTime::toTime_t with QDateTime::toSecsSinceEpoch 3ae503c95bin src/qt/recentrequeststablemodel.h:30 in b237992fc4 outdated
26 | @@ -25,10 +27,10 @@ class RecentRequestEntry 27 | SendCoinsRecipient recipient; 28 | 29 | SERIALIZE_METHODS(RecentRequestEntry, obj) { 30 | - unsigned int date_timet; 31 | - SER_WRITE(obj, date_timet = obj.date.toTime_t()); 32 | + qint64 date_timet;
MarcoFalke commented at 7:02 AM on August 24, 2021:I don't think this can be changed without breaking wallet.dat
fanquake commented at 7:03 AM on August 24, 2021:I'm going to revert this. We can leave it as unrelated.
fanquake force-pushed on Aug 24, 2021hebasto approvedhebasto commented at 7:14 AM on August 24, 2021: memberACK 3ae503c95bccc4899fc881c603d618a824078e7b
MarcoFalke merged this on Aug 24, 2021MarcoFalke closed this on Aug 24, 2021fanquake deleted the branch on Aug 24, 2021sidhujag referenced this in commit f993eafecd on Aug 24, 2021bitcoin-core locked this on Aug 24, 2022ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 05:20 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me