diff options
Diffstat (limited to 'src/core/function/gpg/GpgCommandExecutor.cpp')
-rw-r--r-- | src/core/function/gpg/GpgCommandExecutor.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp index 02d22d07..6718d62a 100644 --- a/src/core/function/gpg/GpgCommandExecutor.cpp +++ b/src/core/function/gpg/GpgCommandExecutor.cpp @@ -197,13 +197,14 @@ void GpgCommandExecutor::ExecuteSync(ExecuteContext context) { GpgFrontend::Thread::TaskRunnerGetter::GetInstance().GetTaskRunner( Thread::TaskRunnerGetter::kTaskRunnerType_External_Process); } - target_task_runner->PostTask(task); // to arvoid dead lock issue we need to check if current thread is the same as // target thread. if it is, we can't call exec() because it will block the // current thread. - if (QThread::currentThread() != target_task_runner->GetThread()) { + if (QThread::currentThread()->currentThreadId() != + target_task_runner->GetThread()->currentThreadId()) { + SPDLOG_TRACE("blocking until gpg command finish..."); // block until task finished // this is to keep reference vaild until task finished looper.exec(); @@ -233,7 +234,7 @@ void GpgCommandExecutor::ExecuteConcurrentlySync(ExecuteContexts contexts) { auto remaining_tasks = contexts.size(); Thread::TaskRunnerPtr target_task_runner = nullptr; - bool need_looper = true; + bool need_looper = false; for (auto &context : contexts) { const auto &cmd = context.cmd; @@ -261,15 +262,16 @@ void GpgCommandExecutor::ExecuteConcurrentlySync(ExecuteContexts contexts) { target_task_runner->PostTask(task); // to arvoid dead lock issue we need to check if current thread is the same - // as - // target thread. if it is, we can't call exec() because it will block the - // current thread. - if (QThread::currentThread() == target_task_runner->GetThread()) { - need_looper = false; + // as target thread. if it is, we can't call exec() because it will block + // the current thread. + if (QThread::currentThread()->currentThreadId() != + target_task_runner->GetThread()->currentThreadId()) { + need_looper = true; } } if (need_looper) { + SPDLOG_TRACE("blocking until concurrent gpg commands finish..."); // block until task finished // this is to keep reference vaild until task finished looper.exec(); |