56 lines
2.6 KiB
Diff
56 lines
2.6 KiB
Diff
|
From d852e44cb5e4ff7b49ba91921517cd0679431c28 Mon Sep 17 00:00:00 2001
|
||
|
From: ivan tkachenko <me@ratijas.tk>
|
||
|
Date: Wed, 1 Mar 2023 01:20:15 +0300
|
||
|
Subject: [PATCH 2/4] Avoid duplicating connections between ref and its ref
|
||
|
model
|
||
|
|
||
|
These two connections should be established once in constructor, not on
|
||
|
every call to setter. Because every time when the setter is called, a
|
||
|
new connections are established which are not bound to the lifetime of
|
||
|
model object being set. But, the model object assigned is not managed
|
||
|
by this Ref object, and will be destroyed without any notice, most
|
||
|
importantly without calling setter with null argument which would be
|
||
|
the only way to clean up these extra connections.
|
||
|
|
||
|
Replaces https://invent.kde.org/plasma/flatpak-kcm/-/merge_requests/38
|
||
|
|
||
|
(cherry picked from commit b114d6e1e598c95ade68ef62c1a39ac32d38a29d)
|
||
|
---
|
||
|
flatpakreference.cpp | 7 +++----
|
||
|
1 file changed, 3 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/flatpakreference.cpp b/flatpakreference.cpp
|
||
|
index a2b5d71..d95f496 100644
|
||
|
--- a/flatpakreference.cpp
|
||
|
+++ b/flatpakreference.cpp
|
||
|
@@ -35,6 +35,9 @@ FlatpakReference::FlatpakReference(FlatpakReferencesModel *parent,
|
||
|
, m_refsModel(refsModel)
|
||
|
{
|
||
|
m_path.append(m_id);
|
||
|
+
|
||
|
+ connect(this, &FlatpakReference::needsLoad, parent, &FlatpakReferencesModel::needsLoad);
|
||
|
+ connect(this, &FlatpakReference::needsSaveChanged, parent, &FlatpakReferencesModel::needsSaveChanged);
|
||
|
}
|
||
|
|
||
|
QString FlatpakReference::name() const
|
||
|
@@ -78,16 +81,12 @@ void FlatpakReference::setPermsModel(FlatpakPermissionModel *permsModel)
|
||
|
if (permsModel != m_permsModel) {
|
||
|
if (m_permsModel) {
|
||
|
disconnect(m_permsModel, &FlatpakPermissionModel::referenceChanged, this, &FlatpakReference::needsLoad);
|
||
|
- disconnect(this, &FlatpakReference::needsLoad, m_refsModel, &FlatpakReferencesModel::needsLoad);
|
||
|
disconnect(m_permsModel, &FlatpakPermissionModel::dataChanged, this, &FlatpakReference::needsSaveChanged);
|
||
|
- disconnect(this, &FlatpakReference::needsSaveChanged, m_refsModel, &FlatpakReferencesModel::needsSaveChanged);
|
||
|
}
|
||
|
m_permsModel = permsModel;
|
||
|
if (m_permsModel) {
|
||
|
connect(m_permsModel, &FlatpakPermissionModel::referenceChanged, this, &FlatpakReference::needsLoad);
|
||
|
- connect(this, &FlatpakReference::needsLoad, m_refsModel, &FlatpakReferencesModel::needsLoad);
|
||
|
connect(m_permsModel, &FlatpakPermissionModel::dataChanged, this, &FlatpakReference::needsSaveChanged);
|
||
|
- connect(this, &FlatpakReference::needsSaveChanged, m_refsModel, &FlatpakReferencesModel::needsSaveChanged);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
--
|
||
|
2.39.2
|
||
|
|