fix: add checks before reading from value
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
ff5f2062c3
commit
e61c8ae17a
@ -165,16 +165,25 @@ QVariant ApplicationManager1Storage::readApplicationValue(const QString &appId,
|
|||||||
const QString &groupName,
|
const QString &groupName,
|
||||||
const QString &valueKey) const noexcept
|
const QString &valueKey) const noexcept
|
||||||
{
|
{
|
||||||
|
if (!m_data.contains(appId)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
auto app = m_data.constFind(appId)->toObject();
|
auto app = m_data.constFind(appId)->toObject();
|
||||||
if (app.isEmpty()) {
|
if (app.isEmpty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!app.contains(groupName)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
auto group = app.constFind(groupName)->toObject();
|
auto group = app.constFind(groupName)->toObject();
|
||||||
if (group.isEmpty()) {
|
if (group.isEmpty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!group.contains(valueKey)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
auto val = group.constFind(valueKey);
|
auto val = group.constFind(valueKey);
|
||||||
if (val->isNull()) {
|
if (val->isNull()) {
|
||||||
return {};
|
return {};
|
||||||
|
Loading…
Reference in New Issue
Block a user