aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/KeyList.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-05-09 14:40:54 +0000
committerSaturneric <[email protected]>2022-05-09 14:40:54 +0000
commit670733f7a90d337d546afab22ddedeedec6d3d67 (patch)
tree2c64c0667d2cac45040257802c40963f89737700 /src/ui/widgets/KeyList.cpp
parentdoc: add entry to developer document. (diff)
downloadGpgFrontend-670733f7a90d337d546afab22ddedeedec6d3d67.tar.gz
GpgFrontend-670733f7a90d337d546afab22ddedeedec6d3d67.zip
fix: fix crash poblem when doing operations
1. refactor GpgFunctionObject to solve shared library problem. 2. fix multi-threading issues in refreshing. 3. improve loading speed for key list 4. improve ui operation 5. do other fixing and improving operations
Diffstat (limited to 'src/ui/widgets/KeyList.cpp')
-rw-r--r--src/ui/widgets/KeyList.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 6292c1a9..237576ad 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -29,6 +29,7 @@
#include "ui/widgets/KeyList.h"
#include <boost/format.hpp>
+#include <mutex>
#include <utility>
#include "core/GpgCoreInit.h"
@@ -63,7 +64,7 @@ void KeyList::init() {
connect(this, &KeyList::SignalRefreshDatabase, SignalStation::GetInstance(),
&SignalStation::SignalKeyDatabaseRefresh);
connect(SignalStation::GetInstance(),
- &SignalStation::SignalKeyDatabaseRefresh, this,
+ &SignalStation::SignalKeyDatabaseRefreshDone, this,
&KeyList::SlotRefresh);
connect(ui_->refreshKeyListButton, &QPushButton::clicked, this,
&KeyList::SlotRefresh);
@@ -154,19 +155,15 @@ void KeyList::AddListGroupTab(
}
void KeyList::SlotRefresh() {
- LOG(INFO) << _("Called");
- emit SignalRefreshStatusBar(_("Refreshing Key List..."), 3000);
- auto thread = QThread::create([this]() {
- std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
- buffered_keys_list_ = nullptr;
- // buffered keys list
- buffered_keys_list_ = GpgKeyGetter::GetInstance().FetchKey();
- });
- connect(thread, &QThread::finished, this, &KeyList::slot_refresh_ui);
- connect(thread, &QThread::finished, thread, &QThread::deleteLater);
+ LOG(INFO) << _("Called") << "address" << this;
+
ui_->refreshKeyListButton->setDisabled(true);
ui_->syncButton->setDisabled(true);
- thread->start();
+
+ emit SignalRefreshStatusBar(_("Refreshing Key List..."), 3000);
+
+ this->buffered_keys_list_ = GpgKeyGetter::GetInstance().FetchKey();
+ this->slot_refresh_ui();
}
KeyIdArgsListPtr KeyList::GetChecked(const KeyTable& key_table) {
@@ -424,7 +421,8 @@ void KeyList::slot_refresh_ui() {
if (buffered_keys_list_ != nullptr) {
std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
for (auto& key_table : m_key_tables_) {
- key_table.Refresh(GpgKeyGetter::GetKeysCopy(buffered_keys_list_));
+ key_table.Refresh(
+ GpgKeyGetter::GetInstance().GetKeysCopy(buffered_keys_list_));
}
}
emit SignalRefreshStatusBar(_("Key List Refreshed."), 1000);