1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Merge pull request #4209 from paperbagcorner/fix-forloop

Iterate over a copy of the parents container since we are removing elements from the original
This commit is contained in:
David Sansome 2014-02-13 21:33:46 +11:00
commit 28873605ff

View File

@ -380,7 +380,11 @@ void LibraryModel::SongsDeleted(const SongList& songs) {
// Now delete empty parents
QSet<QString> divider_keys;
while (!parents.isEmpty()) {
for (LibraryItem* node : parents) {
// Since we are going to remove elements from the container, we
// need a copy to iterate over. If we iterate over the original,
// the behavior will be undefined.
QSet<LibraryItem*> parents_copy = parents;
for (LibraryItem* node : parents_copy) {
parents.remove(node);
if (node->children.count() != 0) continue;