aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-07-27 08:56:19 +0000
committersaturneric <[email protected]>2024-07-27 08:56:19 +0000
commit1c4445408577a3bd5743d344cdd31f21d81dc9c0 (patch)
tree18deeb8cac0c66f831c4dd0f9600487c4855cbdf /src
parentfix: indirect memory leak issues (diff)
downloadGpgFrontend-1c4445408577a3bd5743d344cdd31f21d81dc9c0.tar.gz
GpgFrontend-1c4445408577a3bd5743d344cdd31f21d81dc9c0.zip
fix: discover and solve some memory issues
Diffstat (limited to 'src')
-rw-r--r--src/core/module/GlobalRegisterTable.cpp32
-rw-r--r--src/core/module/GlobalRegisterTableTreeModel.h7
-rw-r--r--src/core/module/ModuleInit.cpp3
-rw-r--r--src/core/module/ModuleManager.cpp6
-rw-r--r--src/ui/widgets/GRTTreeView.cpp2
5 files changed, 25 insertions, 25 deletions
diff --git a/src/core/module/GlobalRegisterTable.cpp b/src/core/module/GlobalRegisterTable.cpp
index bac51d85..c19a9131 100644
--- a/src/core/module/GlobalRegisterTable.cpp
+++ b/src/core/module/GlobalRegisterTable.cpp
@@ -126,8 +126,8 @@ class GlobalRegisterTable::Impl {
return rtn;
}
- auto ListenPublish(QObject* o, const Namespace& n, const Key& k, LPCallback c)
- -> bool {
+ auto ListenPublish(QObject* o, const Namespace& n, const Key& k,
+ LPCallback c) -> bool {
if (o == nullptr) return false;
return QObject::connect(parent_, &GlobalRegisterTable::SignalPublish, o,
[n, k, c](const Namespace& pn, const Key& pk,
@@ -138,7 +138,7 @@ class GlobalRegisterTable::Impl {
}) == nullptr;
}
- auto RootRTNode() -> RTNode* { return root_node_.get(); }
+ auto RootRTNode() -> RTNodePtr { return root_node_; }
private:
std::shared_mutex lock_;
@@ -165,8 +165,8 @@ class GlobalRegisterTableTreeModel::Impl {
return 4;
}
- [[nodiscard]] auto Data(const QModelIndex& index, int role) const
- -> QVariant {
+ [[nodiscard]] auto Data(const QModelIndex& index,
+ int role) const -> QVariant {
if (!index.isValid()) return {};
if (role == Qt::DisplayRole) {
@@ -232,8 +232,8 @@ class GlobalRegisterTableTreeModel::Impl {
return tr("<UNSUPPORTED>");
}
- [[nodiscard]] auto Index(int row, int column, const QModelIndex& parent) const
- -> QModelIndex {
+ [[nodiscard]] auto Index(int row, int column,
+ const QModelIndex& parent) const -> QModelIndex {
if (!parent_->hasIndex(row, column, parent)) return {};
auto* parent_node = !parent.isValid()
@@ -292,8 +292,8 @@ auto GlobalRegisterTable::PublishKV(Namespace n, Key k, std::any v) -> bool {
return p_->PublishKV(n, k, v);
}
-auto GlobalRegisterTable::LookupKV(Namespace n, Key v)
- -> std::optional<std::any> {
+auto GlobalRegisterTable::LookupKV(Namespace n,
+ Key v) -> std::optional<std::any> {
return p_->LookupKV(n, v);
}
@@ -302,14 +302,15 @@ auto GlobalRegisterTable::ListenPublish(QObject* o, Namespace n, Key k,
return p_->ListenPublish(o, n, k, c);
}
-auto GlobalRegisterTable::ListChildKeys(Namespace n, Key k)
- -> std::vector<Key> {
+auto GlobalRegisterTable::ListChildKeys(Namespace n,
+ Key k) -> std::vector<Key> {
return p_->ListChildKeys(n, k);
}
GlobalRegisterTableTreeModel::GlobalRegisterTableTreeModel(
- GlobalRegisterTable* grt)
- : p_(SecureCreateUniqueObject<Impl>(this, grt->p_.get())) {}
+ GlobalRegisterTable* grt, QObject* parent)
+ : QAbstractItemModel(parent),
+ p_(SecureCreateUniqueObject<Impl>(this, grt->p_.get())) {}
auto GlobalRegisterTableTreeModel::rowCount(const QModelIndex& parent) const
-> int {
@@ -326,9 +327,8 @@ auto GlobalRegisterTableTreeModel::data(const QModelIndex& index,
return p_->Data(index, role);
}
-auto GlobalRegisterTableTreeModel::index(int row, int column,
- const QModelIndex& parent) const
- -> QModelIndex {
+auto GlobalRegisterTableTreeModel::index(
+ int row, int column, const QModelIndex& parent) const -> QModelIndex {
return p_->Index(row, column, parent);
}
diff --git a/src/core/module/GlobalRegisterTableTreeModel.h b/src/core/module/GlobalRegisterTableTreeModel.h
index fe4242a2..b7d56cc1 100644
--- a/src/core/module/GlobalRegisterTableTreeModel.h
+++ b/src/core/module/GlobalRegisterTableTreeModel.h
@@ -34,15 +34,16 @@ namespace GpgFrontend::Module {
class GPGFRONTEND_CORE_EXPORT GlobalRegisterTableTreeModel
: public QAbstractItemModel {
public:
- explicit GlobalRegisterTableTreeModel(GlobalRegisterTable *grt);
+ explicit GlobalRegisterTableTreeModel(GlobalRegisterTable *grt,
+ QObject *parent);
[[nodiscard]] auto rowCount(const QModelIndex &parent) const -> int override;
[[nodiscard]] auto columnCount(const QModelIndex &parent) const
-> int override;
- [[nodiscard]] auto data(const QModelIndex &index, int role) const
- -> QVariant override;
+ [[nodiscard]] auto data(const QModelIndex &index,
+ int role) const -> QVariant override;
[[nodiscard]] auto index(int row, int column, const QModelIndex &parent) const
-> QModelIndex override;
diff --git a/src/core/module/ModuleInit.cpp b/src/core/module/ModuleInit.cpp
index 0e41e949..dc001798 100644
--- a/src/core/module/ModuleInit.cpp
+++ b/src/core/module/ModuleInit.cpp
@@ -68,14 +68,13 @@ auto LoadIntegratedMods() -> bool {
}
if (!QDir(mods_path).exists()) {
- qCWarning(core) << "integrated module directory at path " << mods_path
+ qCWarning(core) << "integrated module directory at path: " << mods_path
<< " not found, abort...";
return false;
}
LoadModuleFromPath(mods_path, true);
- qCDebug(core, "load integrated modules done.");
return true;
}
diff --git a/src/core/module/ModuleManager.cpp b/src/core/module/ModuleManager.cpp
index ad4f9ceb..45e9f657 100644
--- a/src/core/module/ModuleManager.cpp
+++ b/src/core/module/ModuleManager.cpp
@@ -60,9 +60,9 @@ class ModuleManager::Impl {
[=](GpgFrontend::DataObjectPtr) -> int {
QLibrary module_library(module_library_path);
if (!module_library.load()) {
- qCWarning(core) << "module manager failed to load module, "
- "reason: broken library: "
- << module_library.fileName();
+ qCWarning(core) << "module manager failed to load module: "
+ << module_library.fileName()
+ << ", reason: " << module_library.errorString();
return -1;
}
diff --git a/src/ui/widgets/GRTTreeView.cpp b/src/ui/widgets/GRTTreeView.cpp
index 09d7dcf0..b52f6881 100644
--- a/src/ui/widgets/GRTTreeView.cpp
+++ b/src/ui/widgets/GRTTreeView.cpp
@@ -35,7 +35,7 @@ namespace GpgFrontend::UI {
GRTTreeView::GRTTreeView(QWidget* parent) : QTreeView(parent) {
setModel(new Module::GlobalRegisterTableTreeModel(
- Module::ModuleManager::GetInstance().GRT()));
+ Module::ModuleManager::GetInstance().GRT(), this));
connect(model(), &QFileSystemModel::layoutChanged, this,
&GRTTreeView::slot_adjust_column_widths);