From d833940f3cb44aad3ff0e91b7c9e3d4d689c545f Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Thu, 30 May 2024 08:29:48 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkcore Synchronize source files from linuxdeepin/dtkcore. Source-pull-request: https://github.com/linuxdeepin/dtkcore/pull/425 --- include/global/dconfigfile.h | 4 +++- src/dconfigfile.cpp | 13 +++++++++---- src/log/LogManager.cpp | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/global/dconfigfile.h b/include/global/dconfigfile.h index 5959fd9..37543ef 100644 --- a/include/global/dconfigfile.h +++ b/include/global/dconfigfile.h @@ -35,7 +35,9 @@ class LIBDTKCORESHARED_EXPORT DConfigFile : public DObject{ enum Permissions { ReadOnly, - ReadWrite + ReadWrite, + AuthorizedReadOnly, + AuthorizedReadWrite, }; enum Visibility { diff --git a/src/dconfigfile.cpp b/src/dconfigfile.cpp index 896248a..59190eb 100644 --- a/src/dconfigfile.cpp +++ b/src/dconfigfile.cpp @@ -335,8 +335,13 @@ class Q_DECL_HIDDEN DConfigInfo { { DConfigFile::Permissions p = DConfigFile::ReadOnly; const auto &tmp = values[key][QLatin1String("permissions")].toString(); - if (tmp == QLatin1String("readwrite")) + if (tmp == QLatin1String("readwrite")) { p = DConfigFile::ReadWrite; + } else if (tmp == QLatin1String("authorizedreadonly")) { + p = DConfigFile::AuthorizedReadOnly; + } else if (tmp == QLatin1String("authorizedreadwrite")) { + p = DConfigFile::AuthorizedReadWrite; + } return p; } @@ -1049,7 +1054,7 @@ class Q_DECL_HIDDEN DConfigCacheImpl : public DConfigCache { homePath = DStandardPaths::homePath(getuid()); } - if (homePath.isEmpty()) + if (homePath.isEmpty() || !QDir().exists(homePath)) return QString(); // fallback to default application cache directory. @@ -1207,7 +1212,7 @@ bool DConfigCacheImpl::save(const QString &localPrefix, QJsonDocument::JsonForma cacheChanged = false; const QString &dir = getCacheDir(localPrefix); if (dir.isEmpty()) { - qCWarning(cfLog, "Falied on saveing, the config cache directory is empty for the user[%d], " + qCWarning(cfLog, "Failed on saving, the config cache directory is empty for the user[%d], " "the current user[%d].", userid, getuid()); return false; } @@ -1219,7 +1224,7 @@ bool DConfigCacheImpl::save(const QString &localPrefix, QJsonDocument::JsonForma } if (!cache.open(QIODevice::WriteOnly)) { - qCWarning(cfLog, "Falied on saveing data when open file: \"%s\", error message: \"%s\"", + qCWarning(cfLog, "Failed on saving data when open file: \"%s\", error message: \"%s\"", qPrintable(cache.fileName()), qPrintable(cache.errorString())); return false; } diff --git a/src/log/LogManager.cpp b/src/log/LogManager.cpp index 3d0d82e..390a70f 100644 --- a/src/log/LogManager.cpp +++ b/src/log/LogManager.cpp @@ -108,7 +108,7 @@ void DLogManagerPrivate::updateLoggingRules() var = m_dsgConfig->value(RULES_KEY); } else if (m_fallbackConfig && !m_fallbackConfig->isDefaultValue(RULES_KEY)) { var = m_fallbackConfig->value(RULES_KEY); - } else { + } else if (m_dsgConfig) { var = m_dsgConfig->value(RULES_KEY); }