aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-02-18 11:12:03 +0000
committerSaturneric <[email protected]>2023-02-18 11:12:03 +0000
commit3b062240c399bc7fb24fde3442db407386c17161 (patch)
tree06f41cd7928ae1f5ab2b935203d8399dab11373a
parentfix: improve stability of the object-channel model (diff)
downloadGpgFrontend-3b062240c399bc7fb24fde3442db407386c17161.tar.gz
GpgFrontend-3b062240c399bc7fb24fde3442db407386c17161.zip
fix: improve the task execution model
-rw-r--r--src/core/GpgContext.cpp41
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.cpp13
-rw-r--r--src/core/thread/CtxCheckTask.cpp2
-rw-r--r--src/core/thread/FileReadTask.cpp4
-rw-r--r--src/core/thread/Task.cpp86
-rw-r--r--src/core/thread/Task.h41
-rw-r--r--src/core/thread/TaskRunner.cpp98
-rw-r--r--src/core/thread/TaskRunner.h6
-rw-r--r--src/ui/GpgFrontendUIInit.cpp14
-rw-r--r--src/ui/UserInterfaceUtils.cpp13
-rw-r--r--src/ui/dialog/settings/SettingsKeyServer.cpp2
-rw-r--r--src/ui/thread/KeyServerImportTask.cpp2
-rw-r--r--src/ui/thread/KeyServerSearchTask.cpp2
-rw-r--r--src/ui/thread/ListedKeyServerTestTask.cpp2
-rw-r--r--src/ui/thread/VersionCheckTask.cpp6
-rw-r--r--src/ui/widgets/PlainTextEditorPage.cpp4
16 files changed, 220 insertions, 116 deletions
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp
index 613767a7..a5213134 100644
--- a/src/core/GpgContext.cpp
+++ b/src/core/GpgContext.cpp
@@ -408,7 +408,7 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
SPDLOG_DEBUG("start to get dirs info");
- GpgCommandExecutor::GetInstance().Execute(
+ GpgCommandExecutor::GetInstance().ExecuteConcurrently(
info_.GpgConfPath, {"--list-dirs"},
[=](int exit_code, const std::string &p_out, const std::string &p_err) {
SPDLOG_DEBUG(
@@ -457,20 +457,20 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
if (component.first == "gpgme" || component.first == "gpgconf") continue;
- GpgCommandExecutor::GetInstance().Execute(
+ GpgCommandExecutor::GetInstance().ExecuteConcurrently(
info_.GpgConfPath, {"--check-options", component.first},
[=](int exit_code, const std::string &p_out,
const std::string &p_err) {
SPDLOG_DEBUG(
- "gpgconf options exit_code: {} process stdout size: {} "
- "component: {} ",
- exit_code, p_out.size(), component.first);
+ "gpgconf {} options exit_code: {} process stdout "
+ "size: {} ",
+ component.first, exit_code, p_out.size());
if (exit_code != 0) {
SPDLOG_ERROR(
- "gpgconf execute error, process stderr: {} , process "
- "stdout:",
- p_err, p_out);
+ "gpgconf {} options execute error, process "
+ "stderr: {} , process stdout:",
+ component.first, p_err, p_out);
return;
}
@@ -483,8 +483,8 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
std::vector<std::string> info_split_list;
boost::split(info_split_list, line, boost::is_any_of(":"));
- SPDLOG_DEBUG("gpgconf info line: {} info size: {}", line,
- info_split_list.size());
+ SPDLOG_DEBUG("component {} options line: {} info size: {}",
+ component.first, line, info_split_list.size());
if (info_split_list.size() != 6) continue;
@@ -500,27 +500,27 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
});
}
- SPDLOG_DEBUG("start to get component options info");
+ SPDLOG_DEBUG("start to get avaliable component options info");
for (const auto &component : info_.ComponentsInfo) {
SPDLOG_DEBUG("gpgconf list options ready", "component", component.first);
if (component.first == "gpgme" || component.first == "gpgconf") continue;
- GpgCommandExecutor::GetInstance().Execute(
+ GpgCommandExecutor::GetInstance().ExecuteConcurrently(
info_.GpgConfPath, {"--list-options", component.first},
[=](int exit_code, const std::string &p_out,
const std::string &p_err) {
SPDLOG_DEBUG(
- "gpgconf options exit_code: {} process stdout size: {} "
- "component: {} ",
- exit_code, p_out.size(), component.first);
+ "gpgconf {} avaliable options exit_code: {} process stdout "
+ "size: {} ",
+ component.first, exit_code, p_out.size());
if (exit_code != 0) {
SPDLOG_ERROR(
- "gpgconf execute error, process stderr: {} , process "
- "stdout:",
- p_err, p_out);
+ "gpgconf {} avaliable options execute error, process stderr: "
+ "{} , process stdout:",
+ component.first, p_err, p_out);
return;
}
@@ -533,8 +533,9 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
std::vector<std::string> info_split_list;
boost::split(info_split_list, line, boost::is_any_of(":"));
- SPDLOG_DEBUG("gpgconf info line: {} info size: {}", line,
- info_split_list.size());
+ SPDLOG_DEBUG(
+ "component {} avaliable options line: {} info size: {}",
+ component.first, line, info_split_list.size());
if (info_split_list.size() != 10) continue;
diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp
index 30984697..86c47c60 100644
--- a/src/core/function/gpg/GpgCommandExecutor.cpp
+++ b/src/core/function/gpg/GpgCommandExecutor.cpp
@@ -29,7 +29,6 @@
#include "GpgFunctionObject.h"
#include "core/thread/TaskRunnerGetter.h"
-#include "spdlog/fmt/bundled/format.h"
GpgFrontend::GpgCommandExecutor::GpgCommandExecutor(int channel)
: SingletonFunctionObject<GpgCommandExecutor>(channel) {}
@@ -42,6 +41,7 @@ void GpgFrontend::GpgCommandExecutor::Execute(
Thread::Task::TaskCallback result_callback =
[](int rtn, Thread::Task::DataObjectPtr data_object) {
+ SPDLOG_DEBUG("data object use count: {}", data_object.use_count());
if (data_object->GetObjectSize() != 4)
throw std::runtime_error("invalid data object size");
@@ -121,26 +121,30 @@ void GpgFrontend::GpgCommandExecutor::Execute(
cmd_process->deleteLater();
// transfer result
+ SPDLOG_DEBUG("runner append object");
data_object->AppendObject(std::move(process_stderr));
data_object->AppendObject(std::move(process_stdout));
data_object->AppendObject(std::move(exit_code));
+ SPDLOG_DEBUG("runner append object done");
return 0;
};
// data transfer into task
auto data_object = std::make_shared<Thread::Task::DataObject>();
+ SPDLOG_DEBUG("executor append object");
data_object->AppendObject(std::move(callback));
data_object->AppendObject(std::move(interact_func));
data_object->AppendObject(std::move(arguments));
data_object->AppendObject(std::move(std::string{cmd}));
+ SPDLOG_DEBUG("executor append object done");
auto *process_task = new GpgFrontend::Thread::Task(
std::move(runner), fmt::format("Execute/{}", cmd), data_object,
std::move(result_callback));
QEventLoop looper;
- QObject::connect(process_task, &Thread::Task::SignalTaskFinished, &looper,
+ QObject::connect(process_task, &Thread::Task::SignalTaskEnd, &looper,
&QEventLoop::quit);
GpgFrontend::Thread::TaskRunnerGetter::GetInstance()
@@ -181,11 +185,13 @@ void GpgFrontend::GpgCommandExecutor::ExecuteConcurrently(
if (data_object->GetObjectSize() != 4)
throw std::runtime_error("invalid data object size");
+ SPDLOG_DEBUG("runner pop object");
// get arguments
auto cmd = data_object->PopObject<std::string>();
auto arguments = data_object->PopObject<std::vector<std::string>>();
auto interact_func =
data_object->PopObject<std::function<void(QProcess *)>>();
+ SPDLOG_DEBUG("runner pop object done");
auto *cmd_process = new QProcess();
cmd_process->setProcessChannelMode(QProcess::MergedChannels);
@@ -216,6 +222,7 @@ void GpgFrontend::GpgCommandExecutor::ExecuteConcurrently(
});
cmd_process->setProgram(QString::fromStdString(cmd));
+ cmd_process->setProcessChannelMode(QProcess::SeparateChannels);
QStringList q_arguments;
for (const auto &argument : arguments)
@@ -238,9 +245,11 @@ void GpgFrontend::GpgCommandExecutor::ExecuteConcurrently(
cmd_process->deleteLater();
// transfer result
+ SPDLOG_DEBUG("runner append object");
data_object->AppendObject(std::move(process_stderr));
data_object->AppendObject(std::move(process_stdout));
data_object->AppendObject(std::move(exit_code));
+ SPDLOG_DEBUG("runner append object done");
return 0;
};
diff --git a/src/core/thread/CtxCheckTask.cpp b/src/core/thread/CtxCheckTask.cpp
index eef05b1b..9735fcaa 100644
--- a/src/core/thread/CtxCheckTask.cpp
+++ b/src/core/thread/CtxCheckTask.cpp
@@ -49,4 +49,6 @@ void GpgFrontend::Thread::CtxCheckTask::Run() {
// Try flushing key cache
else
GpgFrontend::GpgKeyGetter::GetInstance().FlushKeyCache();
+
+ SPDLOG_DEBUG("ctx check task runnable done");
}
diff --git a/src/core/thread/FileReadTask.cpp b/src/core/thread/FileReadTask.cpp
index 0888e029..73954d28 100644
--- a/src/core/thread/FileReadTask.cpp
+++ b/src/core/thread/FileReadTask.cpp
@@ -73,8 +73,8 @@ void FileReadTask::read_bytes() {
} else {
SPDLOG_DEBUG("read bytes end");
emit SignalFileBytesReadEnd();
- // finish task
- emit SignalTaskFinished();
+ // announce finish task
+ emit SignalTaskRunnableEnd(0);
}
}
diff --git a/src/core/thread/Task.cpp b/src/core/thread/Task.cpp
index 823276ae..937211cf 100644
--- a/src/core/thread/Task.cpp
+++ b/src/core/thread/Task.cpp
@@ -90,28 +90,49 @@ std::string GpgFrontend::Thread::Task::GetUUID() const { return uuid_; }
bool GpgFrontend::Thread::Task::GetSequency() const { return sequency_; }
-void GpgFrontend::Thread::Task::SetFinishAfterRun(bool finish_after_run) {
- this->finish_after_run_ = finish_after_run;
+void GpgFrontend::Thread::Task::SetFinishAfterRun(
+ bool run_callback_after_runnable_finished) {
+ this->run_callback_after_runnable_finished_ =
+ run_callback_after_runnable_finished;
}
void GpgFrontend::Thread::Task::SetRTN(int rtn) { this->rtn_ = rtn; }
void GpgFrontend::Thread::Task::init() {
- connect(this, &Task::SignalTaskFinished, this, &Task::before_finish_task);
+ // after runnable finished, running callback
+ connect(this, &Task::SignalTaskRunnableEnd, this,
+ &Task::slot_task_run_callback);
}
-void GpgFrontend::Thread::Task::before_finish_task() {
- SPDLOG_TRACE("task {} finished", GetFullID());
+void GpgFrontend::Thread::Task::slot_task_run_callback(int rtn) {
+ SPDLOG_TRACE("task runnable {} finished, rtn: {}", GetFullID(), rtn);
+ // set return value
+ this->SetRTN(rtn);
try {
if (callback_) {
- bool if_invoke = QMetaObject::invokeMethod(
- callback_thread_,
- [callback = callback_, rtn = rtn_, data_object = data_object_]() {
- callback(rtn, data_object);
- });
- if (!if_invoke) {
- SPDLOG_ERROR("failed to invoke callback");
+ if (callback_thread_ == QThread::currentThread()) {
+ SPDLOG_DEBUG("callback thread is the same thread");
+ if (!QMetaObject::invokeMethod(callback_thread_,
+ [callback = callback_, rtn = rtn_,
+ data_object = data_object_, this]() {
+ callback(rtn, data_object);
+ // do cleaning work
+ emit SignalTaskEnd();
+ })) {
+ SPDLOG_ERROR("failed to invoke callback");
+ }
+ // just finished, let callack thread to raise SignalTaskEnd
+ return;
+ } else {
+ // waiting for callback to finish
+ if (!QMetaObject::invokeMethod(
+ callback_thread_,
+ [callback = callback_, rtn = rtn_,
+ data_object = data_object_]() { callback(rtn, data_object); },
+ Qt::BlockingQueuedConnection)) {
+ SPDLOG_ERROR("failed to invoke callback");
+ }
}
}
} catch (std::exception &e) {
@@ -119,22 +140,45 @@ void GpgFrontend::Thread::Task::before_finish_task() {
} catch (...) {
SPDLOG_ERROR("unknown exception caught");
}
- emit SignalTaskPostFinishedDone();
+
+ // raise signal, announcing this task come to an end
+ SPDLOG_DEBUG("task {}, starting calling signal SignalTaskEnd", GetFullID());
+ emit SignalTaskEnd();
}
void GpgFrontend::Thread::Task::run() {
- SPDLOG_TRACE("task {} started", GetFullID());
- Run();
- if (finish_after_run_) emit SignalTaskFinished();
+ SPDLOG_TRACE("task {} starting", GetFullID());
+
+ // build runnable package for running
+ auto runnable_package = [=, id = GetFullID()]() {
+ SPDLOG_DEBUG("task {} runnable start runing", id);
+ // Run() will set rtn by itself
+ Run();
+ // raise signal to anounce after runnable returned
+ if (run_callback_after_runnable_finished_) emit SignalTaskRunnableEnd(rtn_);
+ };
+
+ if (thread() != QThread::currentThread()) {
+ SPDLOG_DEBUG("task running thread is not object living thread");
+ // running in another thread, blocking until returned
+ if (!QMetaObject::invokeMethod(thread(), runnable_package,
+ Qt::BlockingQueuedConnection)) {
+ SPDLOG_ERROR("qt invoke method failed");
+ }
+ } else {
+ if (!QMetaObject::invokeMethod(this, runnable_package)) {
+ SPDLOG_ERROR("qt invoke method failed");
+ }
+ }
}
+void GpgFrontend::Thread::Task::SlotRun() { run(); }
+
void GpgFrontend::Thread::Task::Run() {
if (runnable_) {
- bool if_invoke = QMetaObject::invokeMethod(
- this, [=]() { return runnable_(data_object_); }, &rtn_);
- if (!if_invoke) {
- SPDLOG_ERROR("qt invokeMethod failed");
- }
+ SetRTN(runnable_(data_object_));
+ } else {
+ SPDLOG_WARN("no runnable in task, do callback operation");
}
}
diff --git a/src/core/thread/Task.h b/src/core/thread/Task.h
index d239cfee..ce354697 100644
--- a/src/core/thread/Task.h
+++ b/src/core/thread/Task.h
@@ -219,18 +219,26 @@ class GPGFRONTEND_CORE_EXPORT Task : public QObject, public QRunnable {
*/
bool GetSequency() const;
- signals:
+ public slots:
+
/**
* @brief
*
*/
- void SignalTaskFinished();
+ void SlotRun();
+ signals:
/**
- * @brief
+ * @brief announce runnable finished
+ *
+ */
+ void SignalTaskRunnableEnd(int rtn);
+
+ /**
+ * @brief runnable and callabck all finished
*
*/
- void SignalTaskPostFinishedDone();
+ void SignalTaskEnd();
protected:
/**
@@ -250,38 +258,39 @@ class GPGFRONTEND_CORE_EXPORT Task : public QObject, public QRunnable {
private:
const std::string uuid_;
const std::string name_;
- const bool sequency_ = true; ///< must run in the same thread
- TaskCallback callback_; ///<
- TaskRunnable runnable_; ///<
- bool finish_after_run_ = true; ///<
- int rtn_ = 0; ///<
- QThread *callback_thread_ = nullptr; ///<
- DataObjectPtr data_object_ = nullptr; ///<
+ const bool sequency_ = true; ///< must run in the same thread
+ TaskCallback callback_; ///<
+ TaskRunnable runnable_; ///<
+ bool run_callback_after_runnable_finished_ = true; ///<
+ int rtn_ = 0; ///<
+ QThread *callback_thread_ = nullptr; ///<
+ DataObjectPtr data_object_ = nullptr; ///<
/**
* @brief
*
*/
- void before_finish_task();
+ void init();
/**
* @brief
*
*/
- void init();
+ virtual void run() override;
/**
* @brief
*
+ * @return std::string
*/
- virtual void run() override;
+ static std::string generate_uuid();
+ private slots:
/**
* @brief
*
- * @return std::string
*/
- static std::string generate_uuid();
+ void slot_task_run_callback(int rtn);
};
} // namespace GpgFrontend::Thread
diff --git a/src/core/thread/TaskRunner.cpp b/src/core/thread/TaskRunner.cpp
index 29aad68b..b60a4b89 100644
--- a/src/core/thread/TaskRunner.cpp
+++ b/src/core/thread/TaskRunner.cpp
@@ -44,19 +44,6 @@ void GpgFrontend::Thread::TaskRunner::PostTask(Task* task) {
task->setParent(nullptr);
task->moveToThread(this);
- connect(task, &Task::SignalTaskPostFinishedDone, this, [&, this, task]() {
- SPDLOG_DEBUG("cleaning task {}", task->GetFullID());
- auto pending_task = pending_tasks_.find(task->GetUUID());
- if (pending_task == pending_tasks_.end()) {
- SPDLOG_ERROR("cannot find task in pending list: {}", task->GetFullID());
- return;
- } else {
- std::lock_guard<std::mutex> lock(tasks_mutex_);
- pending_tasks_.erase(pending_task);
- }
- task->deleteLater();
- });
-
{
std::lock_guard<std::mutex> lock(tasks_mutex_);
tasks.push(task);
@@ -71,14 +58,13 @@ void GpgFrontend::Thread::TaskRunner::PostScheduleTask(Task* task,
}
[[noreturn]] void GpgFrontend::Thread::TaskRunner::run() {
- SPDLOG_TRACE("run, thread id: {}", QThread::currentThreadId());
+ SPDLOG_TRACE("task runner runing, thread id: {}", QThread::currentThreadId());
while (true) {
- SPDLOG_TRACE("task runner: a new cycle start");
if (tasks.empty()) {
- SPDLOG_TRACE("task runner: no tasks to run, trapping into event loop...");
+ SPDLOG_TRACE("no tasks to run, trapping into event loop...");
exec();
} else {
- SPDLOG_TRACE("task runner: task queue size:", tasks.size());
+ SPDLOG_TRACE("start to run task(s), queue size: {}", tasks.size());
Task* task = nullptr;
{
@@ -90,30 +76,76 @@ void GpgFrontend::Thread::TaskRunner::PostScheduleTask(Task* task,
if (task != nullptr) {
try {
- // Run the task
- SPDLOG_TRACE("task runner: running task {}, sequency: {}",
- task->GetFullID(), task->GetSequency());
- if (task->GetSequency()) {
- // run sequently
- task->run();
- } else {
- // run concurrently
- thread_pool_.start(task);
- }
+ // triger
+ SPDLOG_TRACE("running task {}, sequency: {}", task->GetFullID(),
+ task->GetSequency());
+
+ // run sequently
+ // when a signal SignalTaskEnd raise, do unregister work
+ connect(task, &Task::SignalTaskEnd, this, [this, task]() {
+ unregister_finished_task(task->GetUUID());
+ });
+ // run task
+ task->run();
+ // if (task->GetSequency()) {
+
+ // } else {
+ // // run concurrently
+ // auto* concurrent_thread = new QThread(nullptr);
+ // task->setParent(nullptr);
+ // task->moveToThread(concurrent_thread);
+ // connect(concurrent_thread, &QThread::started, task,
+ // &Task::SlotRun); connect(task, &Task::SignalTaskPostFinishedDone,
+ // this,
+ // [uuid = task->GetUUID(), this]() {
+ // unregister_finished_task(uuid);
+ // });
+ // connect(task, &Task::SignalTaskPostFinishedDone,
+ // concurrent_thread,
+ // &QThread::quit);
+ // connect(concurrent_thread, &QThread::finished, concurrent_thread,
+ // [task, concurrent_thread]() {
+ // task->deleteLater();
+ // concurrent_thread->deleteLater();
+ // });
+ // // start thread
+ // concurrent_thread->start();
+ // }
} catch (const std::exception& e) {
SPDLOG_ERROR("task runner: exception in task {}, exception: {}",
task->GetFullID(), e.what());
- // destroy the task, remove the task from the pending tasks
- pending_tasks_.erase(task->GetUUID());
- task->deleteLater();
+ // if any exception caught, destroy the task, remove the task from the
+ // pending tasks
+ unregister_finished_task(task->GetUUID());
} catch (...) {
SPDLOG_ERROR("task runner: unknown exception in task: {}",
task->GetFullID());
- // destroy the task, remove the task from the pending tasks
- pending_tasks_.erase(task->GetUUID());
- task->deleteLater();
+ // if any exception caught, destroy the task, remove the task from the
+ // pending tasks
+ unregister_finished_task(task->GetUUID());
}
}
}
}
}
+
+/**
+ * @brief
+ *
+ */
+void GpgFrontend::Thread::TaskRunner::unregister_finished_task(
+ std::string task_uuid) {
+ SPDLOG_DEBUG("cleaning task {}", task_uuid);
+ // search in map
+ auto pending_task = pending_tasks_.find(task_uuid);
+ if (pending_task == pending_tasks_.end()) {
+ SPDLOG_ERROR("cannot find task in pending list: {}", task_uuid);
+ return;
+ } else {
+ std::lock_guard<std::mutex> lock(tasks_mutex_);
+ pending_task->second->deleteLater();
+ pending_tasks_.erase(pending_task);
+ }
+
+ SPDLOG_DEBUG("clean task {} done", task_uuid);
+}
diff --git a/src/core/thread/TaskRunner.h b/src/core/thread/TaskRunner.h
index fff5c368..35cd1a30 100644
--- a/src/core/thread/TaskRunner.h
+++ b/src/core/thread/TaskRunner.h
@@ -80,6 +80,12 @@ class GPGFRONTEND_CORE_EXPORT TaskRunner : public QThread {
std::map<std::string, Task*> pending_tasks_; ///< The pending tasks
std::mutex tasks_mutex_; ///< The task queue mutex
QThreadPool thread_pool_{this}; ///< run non-sequency task
+
+ /**
+ * @brief
+ *
+ */
+ void unregister_finished_task(std::string);
};
} // namespace GpgFrontend::Thread
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp
index 940cf82b..6e41f81f 100644
--- a/src/ui/GpgFrontendUIInit.cpp
+++ b/src/ui/GpgFrontendUIInit.cpp
@@ -50,7 +50,6 @@ extern void init_logging_system();
extern void init_locale();
void InitGpgFrontendUI(QApplication* app) {
-
// init locale
init_locale();
@@ -88,7 +87,7 @@ void InitGpgFrontendUI(QApplication* app) {
waiting_dialog_label->setWordWrap(true);
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
- app->connect(init_ctx_task, &Thread::CtxCheckTask::SignalTaskFinished,
+ app->connect(init_ctx_task, &Thread::CtxCheckTask::SignalTaskEnd,
waiting_dialog, [=]() {
SPDLOG_DEBUG("gpg context loaded");
waiting_dialog->finished(0);
@@ -108,8 +107,8 @@ void InitGpgFrontendUI(QApplication* app) {
// new local event looper
QEventLoop looper;
- app->connect(init_ctx_task, &Thread::CtxCheckTask::SignalTaskFinished,
- &looper, &QEventLoop::quit);
+ app->connect(init_ctx_task, &Thread::CtxCheckTask::SignalTaskEnd, &looper,
+ &QEventLoop::quit);
// start the thread to load the gpg context
Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask(
@@ -207,9 +206,10 @@ void init_locale() {
SPDLOG_DEBUG("lang from settings: {}", lang);
SPDLOG_DEBUG("project name: {}", PROJECT_NAME);
- SPDLOG_DEBUG(
- "locales path: {}",
- GpgFrontend::GlobalSettingStation::GetInstance().GetLocaleDir().u8string());
+ SPDLOG_DEBUG("locales path: {}",
+ GpgFrontend::GlobalSettingStation::GetInstance()
+ .GetLocaleDir()
+ .u8string());
#ifndef WINDOWS
if (!lang.empty()) {
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index 6c3b0726..f944e037 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -123,12 +123,12 @@ void process_operation(QWidget *parent, const std::string &waiting_title,
auto *process_task = new Thread::Task(std::move(func), waiting_title,
data_object, std::move(callback));
- QApplication::connect(process_task, &Thread::Task::SignalTaskFinished, dialog,
+ QApplication::connect(process_task, &Thread::Task::SignalTaskEnd, dialog,
&QDialog::close);
QEventLoop looper;
- QApplication::connect(process_task, &Thread::Task::SignalTaskFinished,
- &looper, &QEventLoop::quit);
+ QApplication::connect(process_task, &Thread::Task::SignalTaskEnd, &looper,
+ &QEventLoop::quit);
// post process task to task runner
Thread::TaskRunnerGetter::GetInstance()
@@ -406,9 +406,10 @@ void CommonUtils::slot_update_key_status() {
}
return 0;
},
- "update_key_status_task");
- connect(refresh_task, &Thread::Task::SignalTaskFinished, this,
- &CommonUtils::SignalKeyDatabaseRefreshDone);
+ "update_key_database_task");
+ connect(refresh_task, &Thread::Task::SignalTaskEnd, this,
+ &CommonUtils::SignalKeyDatabaseRefreshDone,
+ Qt::BlockingQueuedConnection);
// post the task to the default task runner
Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask(
diff --git a/src/ui/dialog/settings/SettingsKeyServer.cpp b/src/ui/dialog/settings/SettingsKeyServer.cpp
index beb09ee8..8719ab9a 100644
--- a/src/ui/dialog/settings/SettingsKeyServer.cpp
+++ b/src/ui/dialog/settings/SettingsKeyServer.cpp
@@ -273,7 +273,7 @@ void KeyserverTab::slot_test_listed_key_server() {
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
waiting_dialog->setModal(true);
- connect(task, &Thread::Task::SignalTaskFinished, [=]() {
+ connect(task, &Thread::Task::SignalTaskEnd, [=]() {
waiting_dialog->close();
waiting_dialog->deleteLater();
});
diff --git a/src/ui/thread/KeyServerImportTask.cpp b/src/ui/thread/KeyServerImportTask.cpp
index b02a4487..fc6a868c 100644
--- a/src/ui/thread/KeyServerImportTask.cpp
+++ b/src/ui/thread/KeyServerImportTask.cpp
@@ -60,6 +60,6 @@ void GpgFrontend::UI::KeyServerImportTask::dealing_reply_from_server() {
emit SignalKeyServerImportResult(network_reply, buffer);
if (result_count_++ == keyids_.size() - 1) {
- emit SignalTaskFinished();
+ emit SignalTaskRunnableEnd(0);
}
} \ No newline at end of file
diff --git a/src/ui/thread/KeyServerSearchTask.cpp b/src/ui/thread/KeyServerSearchTask.cpp
index 1f90565f..863a4ca3 100644
--- a/src/ui/thread/KeyServerSearchTask.cpp
+++ b/src/ui/thread/KeyServerSearchTask.cpp
@@ -56,5 +56,5 @@ void GpgFrontend::UI::KeyServerSearchTask::dealing_reply_from_server() {
buffer = reply_->readAll();
}
emit SignalKeyServerSearchResult(network_reply, buffer);
- emit SignalTaskFinished();
+ emit SignalTaskRunnableEnd(0);
}
diff --git a/src/ui/thread/ListedKeyServerTestTask.cpp b/src/ui/thread/ListedKeyServerTestTask.cpp
index fe87ed06..914cd3d6 100644
--- a/src/ui/thread/ListedKeyServerTestTask.cpp
+++ b/src/ui/thread/ListedKeyServerTestTask.cpp
@@ -84,6 +84,6 @@ void GpgFrontend::UI::ListedKeyServerTestTask::slot_process_network_reply(
if (++result_count_ == urls_.size()) {
emit SignalKeyServerListTestResult(result_);
- emit SignalTaskFinished();
+ emit SignalTaskRunnableEnd(0);
}
}
diff --git a/src/ui/thread/VersionCheckTask.cpp b/src/ui/thread/VersionCheckTask.cpp
index 08571223..9bda0ddd 100644
--- a/src/ui/thread/VersionCheckTask.cpp
+++ b/src/ui/thread/VersionCheckTask.cpp
@@ -65,7 +65,7 @@ void VersionCheckTask::Run() {
} catch (...) {
SPDLOG_ERROR("unknown error occurred");
- emit SignalTaskFinished();
+ emit SignalTaskRunnableEnd(-1);
}
}
@@ -129,7 +129,7 @@ void VersionCheckTask::slot_parse_latest_version_info() {
&VersionCheckTask::slot_parse_current_version_info);
} catch (...) {
SPDLOG_ERROR("current version request create error");
- emit SignalTaskFinished();
+ emit SignalTaskRunnableEnd(-1);
}
}
@@ -166,7 +166,7 @@ void VersionCheckTask::slot_parse_current_version_info() {
}
emit SignalUpgradeVersion(version_);
- emit SignalTaskFinished();
+ emit SignalTaskRunnableEnd(0);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/PlainTextEditorPage.cpp b/src/ui/widgets/PlainTextEditorPage.cpp
index c97537c3..c9a65a4c 100644
--- a/src/ui/widgets/PlainTextEditorPage.cpp
+++ b/src/ui/widgets/PlainTextEditorPage.cpp
@@ -182,10 +182,10 @@ void PlainTextEditorPage::ReadFile() {
connect(this, &PlainTextEditorPage::SignalUIBytesDisplayed, read_task,
&FileReadTask::SignalFileBytesReadNext, Qt::QueuedConnection);
- connect(read_task, &FileReadTask::SignalTaskFinished, this,
+ connect(read_task, &FileReadTask::SignalTaskRunnableEnd, this,
[]() { SPDLOG_DEBUG("read thread closed"); });
connect(this, &PlainTextEditorPage::close, read_task,
- &FileReadTask::SignalTaskFinished);
+ [=]() { read_task->SignalTaskRunnableEnd(0); });
connect(read_task, &FileReadTask::SignalFileBytesReadEnd, this, [=]() {
// set the UI
if (!binary_mode_) text_page->setReadOnly(false);