From f9a49043c35e73fc2d4ffb3ed9b39c33849c43b3 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 15 Dec 2023 21:14:17 +0800 Subject: fix: slove threading and memory issues --- src/core/function/gpg/GpgContext.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/core/function/gpg/GpgContext.cpp') diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index 443c139b..f7223e13 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -46,15 +46,14 @@ namespace GpgFrontend { -class GpgContext::Impl : public SingletonFunctionObject { +class GpgContext::Impl { public: /** * Constructor * Set up gpgme-context, set paths to app-run path */ - Impl(GpgContext *parent, const GpgContextInitArgs &args, int channel) - : SingletonFunctionObject(channel), - parent_(parent), + Impl(GpgContext *parent, const GpgContextInitArgs &args) + : parent_(parent), args_(args), good_(default_ctx_initialize(args) && binary_ctx_initialize(args)) {} @@ -281,14 +280,14 @@ class GpgContext::Impl : public SingletonFunctionObject { assert(p_ctx != nullptr); binary_ctx_ref_ = p_ctx; - if (!common_ctx_initialize(binary_ctx_ref_, args)) { - SPDLOG_ERROR("get new ctx failed, binary"); - return false; - } + // if (!common_ctx_initialize(binary_ctx_ref_, args)) { + // SPDLOG_ERROR("get new ctx failed, binary"); + // return false; + // } - /** Setting the output type must be done at the beginning */ - /** think this means ascii-armor --> ? */ - gpgme_set_armor(binary_ctx_ref_, 0); + // /** Setting the output type must be done at the beginning */ + // /** think this means ascii-armor --> ? */ + // gpgme_set_armor(binary_ctx_ref_, 0); return true; } @@ -301,22 +300,22 @@ class GpgContext::Impl : public SingletonFunctionObject { assert(p_ctx != nullptr); ctx_ref_ = p_ctx; - if (!common_ctx_initialize(ctx_ref_, args)) { - return false; - } + // if (!common_ctx_initialize(ctx_ref_, args)) { + // return false; + // } - gpgme_set_armor(ctx_ref_, 1); + // gpgme_set_armor(ctx_ref_, 1); return true; } }; GpgContext::GpgContext(int channel) : SingletonFunctionObject(channel), - p_(SecureCreateUniqueObject(this, GpgContextInitArgs{}, channel)) {} + p_(SecureCreateUniqueObject(this, GpgContextInitArgs{})) {} GpgContext::GpgContext(const GpgContextInitArgs &args, int channel) : SingletonFunctionObject(channel), - p_(SecureCreateUniqueObject(this, args, channel)) {} + p_(SecureCreateUniqueObject(this, args)) {} auto GpgContext::Good() const -> bool { return p_->Good(); } -- cgit v1.2.3