aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-10-26 14:20:13 +0000
committersaturneric <[email protected]>2024-10-26 14:20:13 +0000
commitaa90cf1eb97e39f99e622753bb0624ed8dff7775 (patch)
treeec2f334903f4d8e9a179dc88d46911a649c02c7d /src/ui
parentfix: should check key status immediately after get it (diff)
downloadGpgFrontend-aa90cf1eb97e39f99e622753bb0624ed8dff7775.tar.gz
GpgFrontend-aa90cf1eb97e39f99e622753bb0624ed8dff7775.zip
fix: should select channel before any gpg operation
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/Wizard.cpp2
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.cpp5
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.cpp6
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.h4
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp4
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp30
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.cpp13
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp3
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp3
-rw-r--r--src/ui/function/SetOwnerTrustLevel.cpp4
-rw-r--r--src/ui/main_window/KeyMgmt.cpp166
-rw-r--r--src/ui/widgets/KeyList.cpp4
12 files changed, 134 insertions, 110 deletions
diff --git a/src/ui/dialog/Wizard.cpp b/src/ui/dialog/Wizard.cpp
index 10b2c449..3a3c0800 100644
--- a/src/ui/dialog/Wizard.cpp
+++ b/src/ui/dialog/Wizard.cpp
@@ -196,7 +196,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) {
int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; }
void KeyGenPage::slot_generate_key_dialog() {
- (new KeyGenDialog(this))->show();
+ (new KeyGenDialog(kGpgFrontendDefaultChannel, this))->show();
wizard()->next();
}
diff --git a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
index c1923190..8c283f66 100644
--- a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
@@ -117,8 +117,9 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
CommonUtils::WaitForOpera(
this, tr("Generating"), [this, keys](const OperaWaitingHd& op_hd) {
KeyPackageOperator::GenerateKeyPackage(
- ui_->outputPathLabel->text(), ui_->nameValueLabel->text(), *keys,
- passphrase_, ui_->includeSecretKeyCheckBox->isChecked(),
+ ui_->outputPathLabel->text(), ui_->nameValueLabel->text(),
+ current_gpg_context_channel_, *keys, passphrase_,
+ ui_->includeSecretKeyCheckBox->isChecked(),
[=](GFError err, const DataObjectPtr&) {
// stop waiting
op_hd();
diff --git a/src/ui/dialog/key_generate/KeygenDialog.cpp b/src/ui/dialog/key_generate/KeygenDialog.cpp
index 37e2ff2c..e29f6b64 100644
--- a/src/ui/dialog/key_generate/KeygenDialog.cpp
+++ b/src/ui/dialog/key_generate/KeygenDialog.cpp
@@ -41,8 +41,9 @@
namespace GpgFrontend::UI {
-KeyGenDialog::KeyGenDialog(QWidget* parent)
- : GeneralDialog(typeid(KeyGenDialog).name(), parent) {
+KeyGenDialog::KeyGenDialog(int channel, QWidget* parent)
+ : GeneralDialog(typeid(KeyGenDialog).name(), parent),
+ default_gpg_context_channel_(channel) {
button_box_ =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@@ -426,6 +427,7 @@ auto KeyGenDialog::create_basic_info_group_box() -> QGroupBox* {
gpg_contexts_combo_box_->addItem(
QString("%1: %2").arg(channel).arg(database_name));
}
+ gpg_contexts_combo_box_->setCurrentIndex(default_gpg_context_channel_);
for (const auto& algo : GenKeyInfo::GetSupportedKeyAlgo()) {
key_type_combo_box_->addItem(std::get<0>(algo));
diff --git a/src/ui/dialog/key_generate/KeygenDialog.h b/src/ui/dialog/key_generate/KeygenDialog.h
index b8d5a6da..8b9757d5 100644
--- a/src/ui/dialog/key_generate/KeygenDialog.h
+++ b/src/ui/dialog/key_generate/KeygenDialog.h
@@ -52,7 +52,7 @@ class KeyGenDialog : public GeneralDialog {
* @param key The key to show details of
* @param parent The parent of this widget
*/
- explicit KeyGenDialog(QWidget* parent = nullptr);
+ explicit KeyGenDialog(int channel, QWidget* parent = nullptr);
signals:
/**
@@ -110,6 +110,8 @@ class KeyGenDialog : public GeneralDialog {
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
QComboBox* gpg_contexts_combo_box_{};
+ int default_gpg_context_channel_;
+
/**
* @brief
*
diff --git a/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
index 398dab40..76eb94c0 100644
--- a/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
@@ -95,8 +95,8 @@ void KeyNewUIDDialog::slot_create_new_uid() {
}
auto error_string = error_stream.readAll();
if (error_string.isEmpty()) {
- if (GpgUIDOperator::GetInstance().AddUID(
- m_key_, name_->text(), comment_->text(), email_->text())) {
+ if (GpgUIDOperator::GetInstance(current_gpg_context_channel_)
+ .AddUID(m_key_, name_->text(), comment_->text(), email_->text())) {
emit finished(1);
emit SignalUIDCreated();
} else {
diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index 9d40391a..b2978938 100644
--- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -218,7 +218,8 @@ void KeyPairOperaTab::CreateOperaMenu() {
void KeyPairOperaTab::slot_export_public_key() {
auto [err, gf_buffer] =
- GpgKeyImportExporter::GetInstance().ExportKey(m_key_, false, true, false);
+ GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
+ .ExportKey(m_key_, false, true, false);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
CommonUtils::RaiseMessageBox(this, err);
return;
@@ -265,7 +266,8 @@ void KeyPairOperaTab::slot_export_short_private_key() {
// export key, if ok was clicked
if (ret == QMessageBox::Ok) {
auto [err, gf_buffer] =
- GpgKeyImportExporter::GetInstance().ExportKey(m_key_, true, true, true);
+ GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
+ .ExportKey(m_key_, true, true, true);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
CommonUtils::RaiseMessageBox(this, err);
return;
@@ -308,8 +310,9 @@ void KeyPairOperaTab::slot_export_private_key() {
// export key, if ok was clicked
if (ret == QMessageBox::Ok) {
- auto [err, gf_buffer] = GpgKeyImportExporter::GetInstance().ExportKey(
- m_key_, true, true, false);
+ auto [err, gf_buffer] =
+ GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
+ .ExportKey(m_key_, true, true, false);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
CommonUtils::RaiseMessageBox(this, err);
return;
@@ -386,8 +389,8 @@ void KeyPairOperaTab::slot_gen_revoke_cert() {
}
if (!m_output_file_name.isEmpty()) {
- GpgKeyOpera::GetInstance().GenerateRevokeCert(
- m_key_, m_output_file_name, code, text);
+ GpgKeyOpera::GetInstance(current_gpg_context_channel_)
+ .GenerateRevokeCert(m_key_, m_output_file_name, code, text);
}
});
@@ -395,8 +398,8 @@ void KeyPairOperaTab::slot_gen_revoke_cert() {
}
void KeyPairOperaTab::slot_modify_password() {
- GpgKeyOpera::GetInstance().ModifyPassword(
- m_key_, [this](GpgError err, const DataObjectPtr&) {
+ GpgKeyOpera::GetInstance(current_gpg_context_channel_)
+ .ModifyPassword(m_key_, [this](GpgError err, const DataObjectPtr&) {
CommonUtils::RaiseMessageBox(this, err);
});
}
@@ -423,7 +426,8 @@ void KeyPairOperaTab::slot_modify_tofu_policy() {
} else if (item == tr("Policy Unknown")) {
tofu_policy = GPGME_TOFU_POLICY_UNKNOWN;
}
- auto err = GpgKeyOpera::GetInstance().ModifyTOFUPolicy(m_key_, tofu_policy);
+ auto err = GpgKeyOpera::GetInstance(current_gpg_context_channel_)
+ .ModifyTOFUPolicy(m_key_, tofu_policy);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
QMessageBox::critical(this, tr("Not Successful"),
tr("Modify TOFU policy not successfully."));
@@ -508,8 +512,9 @@ void KeyPairOperaTab::slot_export_paper_key() {
// export key, if ok was clicked
if (ret == QMessageBox::Ok) {
- auto [err, gf_buffer] = GpgKeyImportExporter::GetInstance().ExportKey(
- m_key_, true, false, true);
+ auto [err, gf_buffer] =
+ GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
+ .ExportKey(m_key_, true, false, true);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
CommonUtils::RaiseMessageBox(this, err);
return;
@@ -562,7 +567,8 @@ void KeyPairOperaTab::slot_import_paper_key() {
if (!Module::IsModuleActivate(kPaperKeyModuleID)) return;
auto [err, gf_buffer] =
- GpgKeyImportExporter::GetInstance().ExportKey(m_key_, false, false, true);
+ GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
+ .ExportKey(m_key_, false, false, true);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
CommonUtils::RaiseMessageBox(this, err);
return;
diff --git a/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
index 4846f58a..87f5e10e 100644
--- a/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
@@ -389,7 +389,8 @@ void KeyPairUIDTab::slot_del_uid() {
if (ret == QMessageBox::Yes) {
for (const auto& uid : *selected_uids) {
- if (!GpgUIDOperator::GetInstance().RevUID(m_key_, uid)) {
+ if (!GpgUIDOperator::GetInstance(current_gpg_context_channel_)
+ .RevUID(m_key_, uid)) {
QMessageBox::critical(
nullptr, tr("Operation Failed"),
tr("An error occurred during the delete %1 operation.").arg(uid));
@@ -423,8 +424,8 @@ void KeyPairUIDTab::slot_set_primary_uid() {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- if (!GpgUIDOperator::GetInstance().SetPrimaryUID(m_key_,
- selected_uids->front())) {
+ if (!GpgUIDOperator::GetInstance(current_gpg_context_channel_)
+ .SetPrimaryUID(m_key_, selected_uids->front())) {
QMessageBox::critical(nullptr, tr("Operation Failed"),
tr("An error occurred during the operation."));
} else {
@@ -520,7 +521,8 @@ void KeyPairUIDTab::slot_del_uid_single() {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- if (!GpgUIDOperator::GetInstance().RevUID(m_key_, selected_uids->front())) {
+ if (!GpgUIDOperator::GetInstance(current_gpg_context_channel_)
+ .RevUID(m_key_, selected_uids->front())) {
QMessageBox::critical(nullptr, tr("Operation Failed"),
tr("An error occurred during the operation."));
} else {
@@ -572,7 +574,8 @@ void KeyPairUIDTab::slot_del_sign() {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- if (!GpgKeyManager::GetInstance().RevSign(m_key_, selected_signs)) {
+ if (!GpgKeyManager::GetInstance(current_gpg_context_channel_)
+ .RevSign(m_key_, selected_signs)) {
QMessageBox::critical(nullptr, tr("Operation Failed"),
tr("An error occurred during the operation."));
}
diff --git a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
index 71963f99..d621e261 100644
--- a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
@@ -70,7 +70,8 @@ void KeySetExpireDateDialog::slot_confirm() {
expires = std::make_unique<QDateTime>(datetime.toLocalTime());
}
- auto err = GpgKeyOpera::GetInstance().SetExpire(m_key_, m_subkey_, expires);
+ auto err = GpgKeyOpera::GetInstance(current_gpg_context_channel_)
+ .SetExpire(m_key_, m_subkey_, expires);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
diff --git a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
index 94194652..d34fb99a 100644
--- a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
@@ -116,7 +116,8 @@ void KeyUIDSignDialog::slot_sign_key(bool clicked) {
for (const auto& uid : *m_uids_) {
// Sign For mKey
- if (!GpgKeyManager::GetInstance().SignKey(m_key_, *keys, uid, expires)) {
+ if (!GpgKeyManager::GetInstance(current_gpg_context_channel_)
+ .SignKey(m_key_, *keys, uid, expires)) {
QMessageBox::critical(
nullptr, tr("Unsuccessful Operation"),
tr("Signature operation failed for UID %1").arg(uid));
diff --git a/src/ui/function/SetOwnerTrustLevel.cpp b/src/ui/function/SetOwnerTrustLevel.cpp
index a15f3525..d3ca33b3 100644
--- a/src/ui/function/SetOwnerTrustLevel.cpp
+++ b/src/ui/function/SetOwnerTrustLevel.cpp
@@ -77,8 +77,8 @@ auto SetOwnerTrustLevel::Exec(int channel, const QString& key_id) -> bool {
trust_level = 1;
}
- bool status =
- GpgKeyManager::GetInstance().SetOwnerTrustLevel(key, trust_level);
+ bool status = GpgKeyManager::GetInstance(channel).SetOwnerTrustLevel(
+ key, trust_level);
if (!status) {
QMessageBox::critical(this, tr("Failed"),
tr("Modify Owner Trust Level failed."));
diff --git a/src/ui/main_window/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp
index 343da2d9..022f3c9f 100644
--- a/src/ui/main_window/KeyMgmt.cpp
+++ b/src/ui/main_window/KeyMgmt.cpp
@@ -353,7 +353,8 @@ void KeyMgmt::delete_keys_with_warning(KeyIdArgsListPtr uidList) {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- GpgKeyOpera::GetInstance().DeleteKeys(std::move(uidList));
+ GpgKeyOpera::GetInstance(key_list_->GetCurrentGpgContextChannel())
+ .DeleteKeys(std::move(uidList));
emit SignalKeyStatusUpdated();
}
}
@@ -402,8 +403,9 @@ void KeyMgmt::SlotExportKeyToClipboard() {
.GetKey(keys_checked->front());
assert(key.IsGood());
- auto [err, gf_buffer] =
- GpgKeyImportExporter::GetInstance().ExportKey(key, false, true, false);
+ auto [err, gf_buffer] = GpgKeyImportExporter::GetInstance(
+ key_list_->GetCurrentGpgContextChannel())
+ .ExportKey(key, false, true, false);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
CommonUtils::RaiseMessageBox(this, err);
return;
@@ -419,40 +421,42 @@ void KeyMgmt::SlotExportKeyToClipboard() {
CommonUtils::WaitForOpera(
this, tr("Exporting"), [=](const OperaWaitingHd& op_hd) {
- GpgKeyImportExporter::GetInstance().ExportKeys(
- *keys, false, true, false, false,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
- CommonUtils::RaiseMessageBox(this, err);
- return;
- }
-
- if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
- FLOG_W("data object checking failed");
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
- QApplication::clipboard()->setText(
- gf_buffer.ConvertToQByteArray());
- });
+ GpgKeyImportExporter::GetInstance(
+ key_list_->GetCurrentGpgContextChannel())
+ .ExportKeys(
+ *keys, false, true, false, false,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ CommonUtils::RaiseMessageBox(this, err);
+ return;
+ }
+
+ if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
+ FLOG_W("data object checking failed");
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
+ QApplication::clipboard()->setText(
+ gf_buffer.ConvertToQByteArray());
+ });
});
}
}
void KeyMgmt::SlotGenerateKeyDialog() {
- (new KeyGenDialog(this))->exec();
+ (new KeyGenDialog(key_list_->GetCurrentGpgContextChannel(), this))->exec();
this->raise();
}
@@ -508,53 +512,56 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() {
CommonUtils::WaitForOpera(
this, tr("Exporting"), [this, keys](const OperaWaitingHd& op_hd) {
- GpgKeyImportExporter::GetInstance().ExportKeys(
- *keys, false, true, false, true,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
- CommonUtils::RaiseMessageBox(this, err);
- return;
- }
-
- if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
- if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
- CommonUtils::RaiseMessageBox(this, err);
- return;
- }
-
- if (gf_buffer.Empty()) {
- QMessageBox::critical(
- this, tr("Error"),
- tr("This key may not be able to export as OpenSSH format. "
- "Please check the key-size of the subkey(s) used to "
- "sign."));
- return;
- }
-
- QString const file_name = QFileDialog::getSaveFileName(
- this, tr("Export OpenSSH Key To File"), "authorized_keys",
- tr("OpenSSH Public Key Files") + "All Files (*)");
-
- if (!file_name.isEmpty()) {
- WriteFileGFBuffer(file_name, gf_buffer);
- emit SignalStatusBarChanged(tr("key(s) exported"));
- }
- });
+ GpgKeyImportExporter::GetInstance(
+ key_list_->GetCurrentGpgContextChannel())
+ .ExportKeys(
+ *keys, false, true, false, true,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ CommonUtils::RaiseMessageBox(this, err);
+ return;
+ }
+
+ if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
+ if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ CommonUtils::RaiseMessageBox(this, err);
+ return;
+ }
+
+ if (gf_buffer.Empty()) {
+ QMessageBox::critical(
+ this, tr("Error"),
+ tr("This key may not be able to export as OpenSSH "
+ "format. "
+ "Please check the key-size of the subkey(s) used to "
+ "sign."));
+ return;
+ }
+
+ QString const file_name = QFileDialog::getSaveFileName(
+ this, tr("Export OpenSSH Key To File"), "authorized_keys",
+ tr("OpenSSH Public Key Files") + "All Files (*)");
+
+ if (!file_name.isEmpty()) {
+ WriteFileGFBuffer(file_name, gf_buffer);
+ emit SignalStatusBarChanged(tr("key(s) exported"));
+ }
+ });
});
}
@@ -610,6 +617,7 @@ void KeyMgmt::SlotImportKeyPackage() {
this, tr("Importing"), [=](const OperaWaitingHd& op_hd) {
KeyPackageOperator::ImportKeyPackage(
key_package_file_name, key_file_name,
+ key_list_->GetCurrentGpgContextChannel(),
[=](GFError err, const DataObjectPtr& data_obj) {
// stop waiting
op_hd();
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index d98081f3..5994abda 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -523,8 +523,8 @@ void KeyList::dragEnterEvent(QDragEnterEvent* event) {
}
void KeyList::import_keys(const QByteArray& in_buffer) {
- auto result =
- GpgKeyImportExporter::GetInstance().ImportKey(GFBuffer(in_buffer));
+ auto result = GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
+ .ImportKey(GFBuffer(in_buffer));
(new KeyImportDetailDialog(current_gpg_context_channel_, result, this));
}