diff options
author | saturneric <[email protected]> | 2025-01-27 15:39:09 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2025-01-27 15:39:09 +0000 |
commit | af1870fd422fc615a7039b998f505f100e98474a (patch) | |
tree | 5453ac586ce694863ecf438136614d3675b83aca /src/init.cpp | |
parent | feat: allow changing sort options by ui at file page (diff) | |
download | GpgFrontend-af1870fd422fc615a7039b998f505f100e98474a.tar.gz GpgFrontend-af1870fd422fc615a7039b998f505f100e98474a.zip |
fix: kill all gnupg daemons in a proper way
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/init.cpp b/src/init.cpp index e1668ec5..54745d65 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -184,18 +184,30 @@ void ShutdownGlobalBasicEnv(const GFCxtWPtr &p_ctx) { } auto clear_gpg_password_cache = - GlobalSettingStation::GetInstance() - .GetSettings() - .value("basic/clear_gpg_password_cache", false) + GetSettings().value("basic/clear_gpg_password_cache", false).toBool(); + + auto kill_all_gnupg_daemon_at_close = + GetSettings() + .value("gnupg/kill_all_gnupg_daemon_at_close", false) .toBool(); - // clear password cache - if (!ctx->unit_test_mode && clear_gpg_password_cache) { - GpgAdvancedOperator::ClearGpgPasswordCache([](int, DataObjectPtr) {}); + + if (!ctx->unit_test_mode && kill_all_gnupg_daemon_at_close) { + GpgAdvancedOperator::KillAllGpgComponents(nullptr); + } else if (!ctx->unit_test_mode && clear_gpg_password_cache) { + GpgAdvancedOperator::ClearGpgPasswordCache(nullptr); } - Thread::TaskRunnerGetter::GetInstance().StopAllTeakRunner(); + // first should shutdown the module system + GpgFrontend::Module::ShutdownGpgFrontendModules(); + + // then shutdown the core + GpgFrontend::DestroyGpgFrontendCore(); - DestroyGpgFrontendCore(); + // deep restart mode + if (ctx->rtn == GpgFrontend::kDeepRestartCode || + ctx->rtn == GpgFrontend::kCrashCode) { + QProcess::startDetached(qApp->arguments()[0], qApp->arguments()); + }; } } // namespace GpgFrontend |