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

Aleix Pol Gonzalez <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 119919e844eaeb0bf38a009af23733feb7c9f860 by Aleix Pol Gonzalez.
Committed on 16/07/2026 at 09:12.
Pushed by ngraham into branch 'Plasma/6.7'.

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/119919e844eaeb0bf38a009af23733feb7c9f860

diff --git a/libdiscover/UpdateModel/UpdateModel.cpp b/libdiscover/UpdateModel/UpdateModel.cpp
index 17b30a345..de409275e 100644
--- a/libdiscover/UpdateModel/UpdateModel.cpp
+++ b/libdiscover/UpdateModel/UpdateModel.cpp
@@ -248,6 +248,16 @@ void UpdateModel::setResources(const QList<AbstractResource *> &resources)
         }
     }
     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.