diff options
author | saturneric <[email protected]> | 2025-04-15 23:43:24 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2025-04-15 23:43:24 +0000 |
commit | c2d072e60a83ec2ce17fb4e3168b99b001bb5ae9 (patch) | |
tree | 795d97fddb3bc094326b87ec5ee854f71b448228 /src | |
parent | fix: do not show commit hash mismatch in flatpak container (diff) | |
download | Modules-c2d072e60a83ec2ce17fb4e3168b99b001bb5ae9.tar.gz Modules-c2d072e60a83ec2ce17fb4e3168b99b001bb5ae9.zip |
fix: crash due to memory bad access
Diffstat (limited to 'src')
-rw-r--r-- | src/m_gpg_info/GnupgTab.cpp | 33 | ||||
-rw-r--r-- | src/m_gpg_info/GnupgTab.h | 31 |
2 files changed, 49 insertions, 15 deletions
diff --git a/src/m_gpg_info/GnupgTab.cpp b/src/m_gpg_info/GnupgTab.cpp index dc4619f..350a1eb 100644 --- a/src/m_gpg_info/GnupgTab.cpp +++ b/src/m_gpg_info/GnupgTab.cpp @@ -110,17 +110,18 @@ GnupgTab::GnupgTab(QWidget* parent) ui_->optionDetailsTable->setFocusPolicy(Qt::NoFocus); ui_->optionDetailsTable->setAlternatingRowColors(true); + connect(this, &GnupgTab::SignalGnuPGInfoGathered, this, + &GnupgTab::slot_process_software_info); + if (GFModuleRetrieveRTValueOrDefaultBool( DUP("ui"), DUP("env.state.gnupg_info_gathering"), 0) == 1) { - process_software_info(); - + slot_process_software_info(); } else { - auto future = QtConcurrent::run(QThreadPool::globalInstance(), - [=]() { gather_gnupg_info(); }); + slot_gather_gnupg_info(); } } -void GnupgTab::process_software_info() { +void GnupgTab::slot_process_software_info() { const auto gnupg_version = UDUP(GFModuleRetrieveRTValueOrDefault( DUP("core"), DUP("gpgme.ctx.gnupg_version"), DUP("2.0.0"))); @@ -322,15 +323,25 @@ void GnupgTab::process_software_info() { ui_->tabWidget->setDisabled(false); } -void GnupgTab::gather_gnupg_info() { +void GnupgTab::slot_gather_gnupg_info() { ui_->loadProgressBar->show(); ui_->tabWidget->setDisabled(true); - if (StartGatheringAllGnuPGInfo() >= 0) { - GFModuleUpsertRTValueBool(DUP("ui"), DUP("env.state.gnupg_info_gathering"), - 1); - process_software_info(); - } + new GnupgTabWatcher(this); +} + +GnupgTabWatcher::GnupgTabWatcher(GnupgTab* tab) { + connect(this, &GnupgTabWatcher::SignalGnuPGInfoGathered, tab, + &GnupgTab::SignalGnuPGInfoGathered); + + auto future = QtConcurrent::run(QThreadPool::globalInstance(), [=]() { + if (StartGatheringAllGnuPGInfo() >= 0) { + GFModuleUpsertRTValueBool(DUP("ui"), + DUP("env.state.gnupg_info_gathering"), 1); + emit SignalGnuPGInfoGathered(); + } + this->deleteLater(); + }); } auto GnupgTabFactory(void*) -> void* { return new GnupgTab(); }
\ No newline at end of file diff --git a/src/m_gpg_info/GnupgTab.h b/src/m_gpg_info/GnupgTab.h index cd7f4a6..d25f0f7 100644 --- a/src/m_gpg_info/GnupgTab.h +++ b/src/m_gpg_info/GnupgTab.h @@ -46,18 +46,41 @@ class GnupgTab : public QWidget { */ explicit GnupgTab(QWidget* parent = nullptr); - private: - std::shared_ptr<Ui_GnuPGInfo> ui_; ///< + signals: /** * @brief * */ - void process_software_info(); + void SignalGnuPGInfoGathered(); + private slots: /** * @brief * */ - void gather_gnupg_info(); + void slot_process_software_info(); + + /** + * @brief + * + */ + void slot_gather_gnupg_info(); + + private: + std::shared_ptr<Ui_GnuPGInfo> ui_; ///< +}; + +class GnupgTabWatcher : public QObject { + Q_OBJECT + public: + /** + * @brief Construct a new Gnupg Tab Watcher object + * + * @param tab + */ + explicit GnupgTabWatcher(GnupgTab* tab); + + signals: + void SignalGnuPGInfoGathered(); }; |