diff options
author | saturneric <[email protected]> | 2024-11-25 13:39:35 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-11-25 13:39:35 +0000 |
commit | 50e2d5cb3deaf3359a68ceaebdaa2abdb2142fd6 (patch) | |
tree | ff0dc0b571bfeb8d3431c239bbffefce3fbb7300 /src/init.cpp | |
parent | test: fix and add KeyGen & SubkeyGen test cases (diff) | |
download | GpgFrontend-50e2d5cb3deaf3359a68ceaebdaa2abdb2142fd6.tar.gz GpgFrontend-50e2d5cb3deaf3359a68ceaebdaa2abdb2142fd6.zip |
fix: solve a race situation at unit test mode
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/init.cpp b/src/init.cpp index 59cd8a32..2c421040 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -29,6 +29,7 @@ #include "init.h" #include "core/GpgCoreInit.h" +#include "core/function/CoreSignalStation.h" #include "core/function/GlobalSettingStation.h" #include "core/function/gpg/GpgAdvancedOperator.h" #include "core/module/ModuleInit.h" @@ -127,7 +128,7 @@ void InitGlobalBasicEnv(const GFCxtWPtr &p_ctx, bool gui_mode) { CoreInitArgs core_init_args; core_init_args.gather_external_gnupg_info = ctx->gather_external_gnupg_info; - core_init_args.unit_test_mode = ctx->load_default_gpg_context; + core_init_args.unit_test_mode = ctx->unit_test_mode; InitGpgFrontendCoreAsync(core_init_args); @@ -159,6 +160,23 @@ void InitLocale() { QLocale::setDefault(target_locale); } +void InitGlobalBasicEnvSync(const GFCxtWPtr &p_ctx) { + QEventLoop loop; + QCoreApplication::connect(CoreSignalStation::GetInstance(), + &CoreSignalStation::SignalGoodGnupgEnv, &loop, + &QEventLoop::quit); + InitGlobalBasicEnv(p_ctx, false); + + auto env_state = + Module::RetrieveRTValueTypedOrDefault<>("core", "env.state.all", 0); + if (env_state == 1) { + qDebug() << "global basic env initialized before the event loop start"; + return; + } + + loop.exec(); +} + void ShutdownGlobalBasicEnv(const GFCxtWPtr &p_ctx) { GFCxtSPtr ctx = p_ctx.lock(); if (ctx == nullptr) { |