Verified Commit 9784f0d1 authored by Fushan Wen's avatar Fushan Wen
Browse files

applets/kicker: delete SystemEntry if it's not valid

This fixes a memory leak.
parent 2cc819f3
Pipeline #177549 passed with stage
in 8 minutes and 8 seconds
......@@ -88,7 +88,9 @@ void SystemModel::refresh()
void SystemModel::populate()
{
qDeleteAll(m_entries);
qDeleteAll(m_invalidEntries);
m_entries.clear();
m_invalidEntries.clear();
auto addIfValid = [=](const SystemEntry::Action action) {
SystemEntry *entry = new SystemEntry(this, action);
......@@ -96,6 +98,8 @@ void SystemModel::populate()
if (entry->isValid()) {
m_entries << entry;
} else {
m_invalidEntries << entry;
}
QObject::connect(entry, &SystemEntry::isValidChanged, this, &AbstractModel::refresh, Qt::UniqueConnection);
......
......@@ -35,4 +35,5 @@ private:
void populate();
QVector<SystemEntry *> m_entries;
decltype(m_entries) m_invalidEntries;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment