aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/utils/CacheUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/utils/CacheUtils.cpp')
-rw-r--r--src/core/utils/CacheUtils.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/utils/CacheUtils.cpp b/src/core/utils/CacheUtils.cpp
index 575634ae..5e8657fa 100644
--- a/src/core/utils/CacheUtils.cpp
+++ b/src/core/utils/CacheUtils.cpp
@@ -33,14 +33,17 @@
namespace GpgFrontend {
void SetTempCacheValue(const QString& key, const QString& value) {
- nlohmann::json cache_json = value.toStdString();
- CacheManager::GetInstance().SaveCache(key, cache_json);
+ QJsonDocument json;
+ json.setObject(QJsonObject({{key, value}}));
+ CacheManager::GetInstance().SaveCache(key, json);
}
auto GetTempCacheValue(const QString& key) -> QString {
- nlohmann::json cache_json = "";
- cache_json = CacheManager::GetInstance().LoadCache(key, cache_json);
- return QString::fromStdString(cache_json.template get<std::string>());
+ QJsonDocument json = CacheManager::GetInstance().LoadCache(key);
+ if (!json.isObject()) return {};
+ auto json_object = json.object();
+ if (!json_object.contains(key) && json_object[key].isString()) return {};
+ return json_object[key].toString();
}
void ResetTempCacheValue(const QString& key) {