From c34e457bf9506ca068491eda41467013b180e544 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 10 Sep 2019 09:42:22 +0200 Subject: [KConfig] port away from deprecated methods in Qt 5.14 Summary: In kconf_update, the ctime usage used to be about metadata change time (buff.st_ctime, before it got ported to the misnamed created()). I ported it to birthTime, because I think date of birth is a more useful way to identify a file than date of permission change which doesn't really matter to us. But in practice, I can't help but wonder if mtime alone wouldn't be enough. For the QStringLiteral("%%1").arg(i) bit, I tested it in tst_qstring, the first % is left untouched. Test Plan: make && ctest Reviewers: mdawson, arichardson, vkrause Reviewed By: vkrause Subscribers: pino, arojas, mlaurent, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D23815 --- src/kconf_update/kconf_update.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/kconf_update/kconf_update.cpp') diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 09537e2f..2c48fa35 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -200,10 +200,11 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly) QFileInfo info(file); KConfigGroup cg(m_config, fileName); - const QDateTime ctime = QDateTime::fromTime_t(cg.readEntry("ctime", 0u)); - const QDateTime mtime = QDateTime::fromTime_t(cg.readEntry("mtime", 0u)); + const QDateTime ctime = QDateTime::fromSecsSinceEpoch(cg.readEntry("ctime", 0u)); + const QDateTime mtime = QDateTime::fromSecsSinceEpoch(cg.readEntry("mtime", 0u)); if (!dirtyOnly || - (ctime != info.created()) || (mtime != info.lastModified())) { + (ctime.isValid() && ctime != info.birthTime()) || + mtime != info.lastModified()) { result.append(file); } } @@ -372,8 +373,10 @@ bool KonfUpdate::updateFile(const QString &filename) QFileInfo info(filename); KConfigGroup cg(m_config, m_currentFilename); - cg.writeEntry("ctime", info.created().toTime_t()); - cg.writeEntry("mtime", info.lastModified().toTime_t()); + if (info.birthTime().isValid()) { + cg.writeEntry("ctime", info.birthTime().toSecsSinceEpoch()); + } + cg.writeEntry("mtime", info.lastModified().toSecsSinceEpoch()); cg.sync(); return true; } -- cgit v1.2.1