changeset 3782:a3fc112b10f1

Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry for breaking it. :D
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 18 Oct 2007 17:07:00 +0300
parents ec989c2cde74
children 9ae0a88420e5
files src/audacious/playlist.c
diffstat 1 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/playlist.c	Thu Oct 18 01:30:05 2007 +0300
+++ b/src/audacious/playlist.c	Thu Oct 18 17:07:00 2007 +0300
@@ -679,15 +679,18 @@
         nsubtunes = tuple->nsubtunes;
         if (nsubtunes > 0)
             parent_tuple = tuple;
-    } else
+        subtune = 1;
+    } else {
         nsubtunes = 0;
-
-    for (subtune = 0; add_flag && subtune < nsubtunes; subtune++) {
+        subtune = 0;
+    }
+
+    for (; add_flag && subtune <= nsubtunes; subtune++) {
         gchar *filename_entry;
         
         if (nsubtunes > 0) {
             filename_entry = g_strdup_printf("%s?%d", filename,
-                parent_tuple->subtunes ? parent_tuple->subtunes[subtune] : subtune + 1);
+                parent_tuple->subtunes ? parent_tuple->subtunes[subtune - 1] : subtune);
             
             /* We're dealing with subtune, let's ask again tuple information
              * to plugin, by passing the ?subtune suffix; this way we get
@@ -708,7 +711,7 @@
 
         PLAYLIST_LOCK(playlist);
 
-        if (pos == -1 && subtune < 1 && nsubtunes < 1) { // the common case
+        if (pos == -1) { // the common case
             GList *element;
             element = g_list_alloc();
             element->data = entry;
@@ -725,12 +728,9 @@
                 } else
                     add_flag = FALSE;
             }
-        } else {
-            playlist->entries = g_list_insert(playlist->entries, entry, pos);
-        }
-
-        PLAYLIST_UNLOCK(playlist);
-
+        } else
+            playlist->entries = g_list_insert(playlist->entries, entry, pos++);
+        
         if (tuple != NULL) {
             const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL);
             entry->title = tuple_formatter_make_title_string(tuple,
@@ -738,7 +738,10 @@
             entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
             entry->tuple = tuple;
         }
+        
+        PLAYLIST_UNLOCK(playlist);
     }
+
     
     if (parent_tuple)
         tuple_free(parent_tuple);