Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkcore
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#425
  • Loading branch information
deepin-ci-robot committed May 30, 2024
1 parent b25cb4f commit d833940
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion include/global/dconfigfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class LIBDTKCORESHARED_EXPORT DConfigFile : public DObject{

enum Permissions {
ReadOnly,
ReadWrite
ReadWrite,
AuthorizedReadOnly,
AuthorizedReadWrite,
};

enum Visibility {
Expand Down
13 changes: 9 additions & 4 deletions src/dconfigfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/log/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit d833940

Please sign in to comment.