diff options
author | saturneric <[email protected]> | 2023-12-15 09:04:59 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-12-15 09:04:59 +0000 |
commit | f5cf83e4b3fdf1e9ae82b00f39e45e189809c419 (patch) | |
tree | cc7d9b764b0274cfce5830e22a1ecc23678bd091 /src/main.cpp | |
parent | fix: slove issues on memory and add asan support for debug (diff) | |
download | GpgFrontend-f5cf83e4b3fdf1e9ae82b00f39e45e189809c419.tar.gz GpgFrontend-f5cf83e4b3fdf1e9ae82b00f39e45e189809c419.zip |
fix: slove some issues on memory and intilizations
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp index d75ba711..a8de6993 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,11 +33,13 @@ #include <cstddef> #include <cstdlib> #include <iostream> +#include <memory> #include <string> #include "GpgFrontendContext.h" #include "app.h" #include "cmd.h" +#include "core/utils/MemoryUtils.h" #include "init.h" #include "spdlog/spdlog.h" @@ -57,6 +59,10 @@ auto main(int argc, char* argv[]) -> int { signal(SIGILL, HandleSignal); #endif + GpgFrontend::GFCxtSPtr ctx = + GpgFrontend::SecureCreateSharedObject<GpgFrontend::GpgFrontendContext>( + argc, argv); + // initialize qt resources Q_INIT_RESOURCE(gpgfrontend); @@ -72,14 +78,7 @@ auto main(int argc, char* argv[]) -> int { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); - auto p_ctx = GpgFrontend::GpgFrontendContext::CreateInstance(argc, argv); - GpgFrontend::GFCxtSPtr ctx = p_ctx.lock(); - if (ctx == nullptr) { - SPDLOG_ERROR("cannot get gpgfrontend context"); - return -1; - } ctx->log_level = spdlog::level::info; - ctx->load_ui_env = false; if (vm.count("help") != 0U) { std::cout << desc << "\n"; @@ -101,13 +100,11 @@ auto main(int argc, char* argv[]) -> int { if (vm.count("test") != 0U) { ctx->gather_external_gnupg_info = false; ctx->load_default_gpg_context = false; - InitGlobalBasicalEnv(p_ctx); + + InitGlobalBasicalEnv(ctx, false); return RunTest(ctx); } - // default mode - ctx->load_ui_env = true; - InitGlobalBasicalEnv(p_ctx); - - return StartApplication(p_ctx); + InitGlobalBasicalEnv(ctx, true); + return StartApplication(ctx); } |