diff options
author | Saturneric <[email protected]> | 2022-05-13 18:58:10 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-05-13 18:58:10 +0000 |
commit | 9a4cee6ca12aab72ca6b921724950c04bdffccc0 (patch) | |
tree | 038086d7138e35dff8e8b5b124e55b2995e7d8db | |
parent | fix: slove shared link problem (diff) | |
download | GpgFrontend-9a4cee6ca12aab72ca6b921724950c04bdffccc0.tar.gz GpgFrontend-9a4cee6ca12aab72ca6b921724950c04bdffccc0.zip |
fix: slove loading issues at init
1. block the main thread until the gpg context is loaded.
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index a5302c7b..e7751ee6 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -72,6 +72,7 @@ void InitGpgFrontendUI() { waiting_dialog->finished(0); waiting_dialog->deleteLater(); }); + QApplication::connect(waiting_dialog, &QProgressDialog::canceled, [=]() { LOG(INFO) << "cancel clicked"; QCoreApplication::quit(); @@ -83,9 +84,18 @@ void InitGpgFrontendUI() { waiting_dialog->show(); waiting_dialog->setFocus(); + // new local event looper + QEventLoop looper; + QApplication::connect(init_ctx_task, + &Thread::CtxCheckTask::SignalTaskFinished, &looper, + &QEventLoop::quit); + // start the thread to load the gpg context Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask( init_ctx_task); + + // block the main thread until the gpg context is loaded + looper.exec(); } int RunGpgFrontendUI() { |