diff --git a/src/ch/blinkenlights/android/vanilla/SongTimeline.java b/src/ch/blinkenlights/android/vanilla/SongTimeline.java index 55a326ef..07191d28 100644 --- a/src/ch/blinkenlights/android/vanilla/SongTimeline.java +++ b/src/ch/blinkenlights/android/vanilla/SongTimeline.java @@ -341,14 +341,22 @@ public final class SongTimeline { cursor.moveToNext(); if (cursor.getLong(0) == e.id) e.populate(cursor); - else - // We weren't able to query this song. - it.remove(); } } cursor.close(); + // The query may have returned zero results or we might + // have failed to populate some songs: Get rid of all + // uninitialized items (where path == null) + Iterator it = songs.iterator(); + while (it.hasNext()) { + Song e = it.next(); + if (e.path == null) { + it.remove(); + } + } + // Revert to the order the songs were saved in. Collections.sort(songs, new FlagComparator());