diff options
Diffstat (limited to '')
-rw-r--r-- | src/init.cpp | 34 | ||||
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 16 |
2 files changed, 29 insertions, 21 deletions
diff --git a/src/init.cpp b/src/init.cpp index 80c34800..955b8a55 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -38,15 +38,14 @@ #include "core/function/GlobalSettingStation.h" #ifdef WINDOWS -int setenv(const char *name, const char *value, int overwrite) -{ - if(!overwrite) { - int errcode = 0; - size_t envsize = 0; - errcode = getenv_s(&envsize, NULL, 0, name); - if(errcode || envsize) return errcode; - } - return _putenv_s(name, value); +int setenv(const char *name, const char *value, int overwrite) { + if (!overwrite) { + int errcode = 0; + size_t envsize = 0; + errcode = getenv_s(&envsize, NULL, 0, name); + if (errcode || envsize) return errcode; + } + return _putenv_s(name, value); } #endif @@ -91,7 +90,7 @@ void shutdown_logging_system() { } void init_global_path_env() { - auto& settings = + auto &settings = GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings(); bool use_custom_gnupg_install_path = false; @@ -115,14 +114,13 @@ void init_global_path_env() { // add custom gnupg install path into env $PATH if (use_custom_gnupg_install_path && !custom_gnupg_install_path.empty()) { std::string path_value = getenv("PATH"); - SPDLOG_DEBUG("PATH: {}", path_value); - setenv( - "PATH", - ((std::filesystem::path{custom_gnupg_install_path} / "bin").u8string() + - ":" + path_value) - .c_str(), - 1); + SPDLOG_DEBUG("Current System PATH: {}", path_value); + setenv("PATH", + ((std::filesystem::path{custom_gnupg_install_path}).u8string() + + ":" + path_value) + .c_str(), + 1); std::string modified_path_value = getenv("PATH"); - SPDLOG_DEBUG("Modified PATH: {}", modified_path_value); + SPDLOG_DEBUG("Modified System PATH: {}", modified_path_value); } } diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index b90493a5..c6360ca7 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -33,9 +33,11 @@ #include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/stdout_color_sinks.h> +#include "core/GpgConstants.h" #include "core/function/GlobalSettingStation.h" #include "core/thread/CtxCheckTask.h" #include "core/thread/TaskRunnerGetter.h" +#include "spdlog/spdlog.h" #include "ui/SignalStation.h" #include "ui/UserInterfaceUtils.h" #include "ui/main_window/MainWindow.h" @@ -178,9 +180,17 @@ void InitGpgFrontendUI(QApplication* app) { int RunGpgFrontendUI(QApplication* app) { // create main window and show it auto main_window = std::make_unique<GpgFrontend::UI::MainWindow>(); - main_window->Init(); - SPDLOG_DEBUG("main window inited"); - main_window->show(); + + // pre-check, if application need to restart + if (CommonUtils::GetInstance()->isApplicationNeedRestart()) { + SPDLOG_DEBUG("application need to restart, before mian window init"); + return DEEP_RESTART_CODE; + } else { + main_window->Init(); + SPDLOG_DEBUG("main window inited"); + main_window->show(); + } + // start the main event loop return app->exec(); } |