[plasma/discover/Plasma/6.6] libdiscover/UpdateModel: UpdatesModel: Remove destroyed resources

Aleix Pol Gonzalez <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 021b7da82c3e8190a300f0352a2c79f78bd38e14 by Aleix Pol Gonzalez.
Committed on 16/07/2026 at 09:13.
Pushed by apol into branch 'Plasma/6.6'.

UpdatesModel: Remove destroyed resources

We do not want stale resources in the stored list.

BUG: 522255


(cherry picked from commit b3e5d9442f9adb9864d3e20c70b7615230c10993)

Co-authored-by: Aleix Pol i Gonzalez <[email protected]>

M  +10   -0    libdiscover/UpdateModel/UpdateModel.cpp

https://invent.kde.org/plasma/discover/-/commit/021b7da82c3e8190a300f0352a2c79f78bd38e14

diff --git a/libdiscover/UpdateModel/UpdateModel.cpp b/libdiscover/UpdateModel/UpdateModel.cpp
index c0f84a9c9..4c21e3eb1 100644
--- a/libdiscover/UpdateModel/UpdateModel.cpp
+++ b/libdiscover/UpdateModel/UpdateModel.cpp
@@ -243,6 +243,16 @@ void UpdateModel::setResources(const QList<AbstractResource *> &resources)
         return;
     }
     m_resources = resources;
+    for (auto resource : std::as_const(resources)) {
+        connect(
+            resource,
+            &QObject::destroyed,
+            this,
+            [this, resource] {
+                m_resources.removeAll(resource);
+            },
+            Qt::UniqueConnection);
+    }
 
     beginResetModel();
     qDeleteAll(m_updateItems);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.