From 6c632d70b391f8b317c68f7db8cfd217f9370995 Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 15 Jan 2024 17:22:32 +0800 Subject: feat: use qt json support components in data object and infos gathering module --- src/ui/struct/CacheObject.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/ui/struct/CacheObject.cpp (limited to 'src/ui/struct/CacheObject.cpp') diff --git a/src/ui/struct/CacheObject.cpp b/src/ui/struct/CacheObject.cpp new file mode 100644 index 00000000..5413a80e --- /dev/null +++ b/src/ui/struct/CacheObject.cpp @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2021 Saturneric + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see . + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "CacheObject.h" + +#include + +#include "core/function/CacheManager.h" + +namespace GpgFrontend::UI { + +CacheObject::CacheObject(QString cache_name) + : cache_name_(std::move(cache_name)) { + GF_UI_LOG_DEBUG("loading cache from: {}", this->cache_name_); + this->QJsonDocument::operator=( + CacheManager::GetInstance().LoadCache(cache_name_)); +} + +CacheObject::~CacheObject() { + CacheManager::GetInstance().SaveCache(cache_name_, *this); +} + +} // namespace GpgFrontend::UI \ No newline at end of file -- cgit v1.2.3 From 4994f4eaa1211d402b791660ad6221154a4c2405 Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 16 Jan 2024 11:49:50 +0800 Subject: fix: make task and threading system safer --- src/ui/struct/CacheObject.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/ui/struct/CacheObject.cpp') diff --git a/src/ui/struct/CacheObject.cpp b/src/ui/struct/CacheObject.cpp index 5413a80e..16c793fc 100644 --- a/src/ui/struct/CacheObject.cpp +++ b/src/ui/struct/CacheObject.cpp @@ -28,8 +28,6 @@ #include "CacheObject.h" -#include - #include "core/function/CacheManager.h" namespace GpgFrontend::UI { -- cgit v1.2.3 From e352e8e6b8d03a24ef5d52eef3e4d370807b5bbd Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 17 Jan 2024 19:39:47 +0800 Subject: fix: find and slove some bugs --- src/ui/struct/CacheObject.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui/struct/CacheObject.cpp') diff --git a/src/ui/struct/CacheObject.cpp b/src/ui/struct/CacheObject.cpp index 16c793fc..bd3b9818 100644 --- a/src/ui/struct/CacheObject.cpp +++ b/src/ui/struct/CacheObject.cpp @@ -34,13 +34,12 @@ namespace GpgFrontend::UI { CacheObject::CacheObject(QString cache_name) : cache_name_(std::move(cache_name)) { - GF_UI_LOG_DEBUG("loading cache from: {}", this->cache_name_); this->QJsonDocument::operator=( - CacheManager::GetInstance().LoadCache(cache_name_)); + CacheManager::GetInstance().LoadDurableCache(cache_name_)); } CacheObject::~CacheObject() { - CacheManager::GetInstance().SaveCache(cache_name_, *this); + CacheManager::GetInstance().SaveDurableCache(cache_name_, *this); } } // namespace GpgFrontend::UI \ No newline at end of file -- cgit v1.2.3