plugin: delete entries after emitting signal
This commit is contained in:
parent
5ff544ceab
commit
1991b4176c
2 changed files with 8 additions and 3 deletions
|
|
@ -380,6 +380,8 @@ void FileSystemModel::applyChanges(const QSet<QString>& removedPaths, const QSet
|
||||||
}
|
}
|
||||||
std::sort(removedIndices.begin(), removedIndices.end(), std::greater<int>());
|
std::sort(removedIndices.begin(), removedIndices.end(), std::greater<int>());
|
||||||
|
|
||||||
|
QList<FileSystemEntry*> toDelete;
|
||||||
|
|
||||||
int start = -1;
|
int start = -1;
|
||||||
int end = -1;
|
int end = -1;
|
||||||
for (int idx : removedIndices) {
|
for (int idx : removedIndices) {
|
||||||
|
|
@ -392,7 +394,7 @@ void FileSystemModel::applyChanges(const QSet<QString>& removedPaths, const QSet
|
||||||
beginRemoveRows(QModelIndex(), end, start);
|
beginRemoveRows(QModelIndex(), end, start);
|
||||||
for (int i = start; i >= end; --i) {
|
for (int i = start; i >= end; --i) {
|
||||||
emit removed(m_entries[i]->path());
|
emit removed(m_entries[i]->path());
|
||||||
m_entries.takeAt(i)->deleteLater();
|
toDelete << m_entries.takeAt(i);
|
||||||
}
|
}
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
|
||||||
|
|
@ -404,7 +406,7 @@ void FileSystemModel::applyChanges(const QSet<QString>& removedPaths, const QSet
|
||||||
beginRemoveRows(QModelIndex(), end, start);
|
beginRemoveRows(QModelIndex(), end, start);
|
||||||
for (int i = start; i >= end; --i) {
|
for (int i = start; i >= end; --i) {
|
||||||
emit removed(m_entries[i]->path());
|
emit removed(m_entries[i]->path());
|
||||||
m_entries.takeAt(i)->deleteLater();
|
toDelete << m_entries.takeAt(i);
|
||||||
}
|
}
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
@ -460,6 +462,7 @@ void FileSystemModel::applyChanges(const QSet<QString>& removedPaths, const QSet
|
||||||
}
|
}
|
||||||
|
|
||||||
emit entriesChanged();
|
emit entriesChanged();
|
||||||
|
qDeleteAll(toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileSystemModel::compareEntries(const FileSystemEntry* a, const FileSystemEntry* b) const {
|
bool FileSystemModel::compareEntries(const FileSystemEntry* a, const FileSystemEntry* b) const {
|
||||||
|
|
|
||||||
|
|
@ -207,15 +207,17 @@ void AppDb::updateApps() {
|
||||||
newIds.insert(entry->property("id").toString());
|
newIds.insert(entry->property("id").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<AppEntry*> toDelete;
|
||||||
for (auto id : m_apps.keys()) {
|
for (auto id : m_apps.keys()) {
|
||||||
if (!newIds.contains(id)) {
|
if (!newIds.contains(id)) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
m_apps.take(id)->deleteLater();
|
toDelete << m_apps.take(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
emit appsChanged();
|
emit appsChanged();
|
||||||
|
qDeleteAll(toDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue