diff options
Diffstat (limited to 'src/ui/main_window/MainWindow.cpp')
-rw-r--r-- | src/ui/main_window/MainWindow.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index b0273d86..a5df66f0 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -29,6 +29,7 @@ #include "MainWindow.h" #include "core/function/GlobalSettingStation.h" +#include "core/function/gpg/GpgAdvancedOperator.h" #include "ui/SignalStation.h" #include "ui/UserInterfaceUtils.h" #include "ui/struct/SettingsObject.h" @@ -128,6 +129,30 @@ void MainWindow::Init() noexcept { ->PostTask(version_task); } + // before application exit + connect(qApp, &QCoreApplication::aboutToQuit, this, []() { + LOG(INFO) << "about to quit process started"; + + auto &settings = GlobalSettingStation::GetInstance().GetUISettings(); + try { + bool clear_gpg_password_cache = + settings.lookup("general.clear_gpg_password_cache"); + + if (clear_gpg_password_cache) { + if (GpgFrontend::GpgAdvancedOperator::GetInstance() + .ClearGpgPasswordCache()) { + LOG(INFO) << "clear gpg password cache done"; + } else { + LOG(ERROR) << "clear gpg password cache error"; + } + } + + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") + << _("clear_gpg_password_cache"); + } + }); + } catch (...) { LOG(FATAL) << _("Critical error occur while loading GpgFrontend."); QMessageBox::critical(nullptr, _("Loading Failed"), |