Code

screen_artist: fix reload in "All tracks"
authorMax Kellermann <max@duempel.org>
Fri, 3 Oct 2008 09:53:28 +0000 (11:53 +0200)
committerMax Kellermann <max@duempel.org>
Fri, 3 Oct 2008 09:53:28 +0000 (11:53 +0200)
The variable "album" was set to _("All tracks") when it was empty.
When reloading the songs, ncmpc was trying to find an album named "All
tracks", which didn't seem to work.  Leave "album" in its canonical
form and generate the title text on demand.

src/screen_artist.c

index 7d3a189527c3666958e6082f022549ceab88c30d..8c5636f57f39b482ab9832269f35d32c7fe7065a 100644 (file)
@@ -213,13 +213,12 @@ load_song_list(struct mpdclient *c)
        assert(album != NULL);
        assert(browser.filelist == NULL);
 
-       if (album[0] == 0) {
-               album = g_strdup(_("All tracks"));
+       if (album[0] == 0)
                browser.filelist =
                        mpdclient_filelist_search_utf8(c, TRUE,
                                                       MPD_TABLE_ARTIST,
                                                       artist);
-       else
+       else
                browser.filelist =
                        mpdclient_filelist_search_utf8(c, TRUE,
                                                       MPD_TABLE_ALBUM,
@@ -373,22 +372,27 @@ paint(mpd_unused mpdclient_t *c)
 static const char *
 get_title(char *str, size_t size)
 {
-       char *s1 = artist ? utf8_to_locale(artist) : NULL;
-       char *s2 = album ? utf8_to_locale(album) : NULL;
+       char *s1, *s2;
 
        switch(mode) {
        case LIST_ARTISTS:
                g_snprintf(str, size,  _("Artist: [db browser - EXPERIMENTAL]"));
                break;
        case LIST_ALBUMS:
+               s1 = utf8_to_locale(artist);
                g_snprintf(str, size,  _("Artist: %s"), s1);
+               g_free(s1);
                break;
        case LIST_SONGS:
+               s1 = utf8_to_locale(artist);
+               s2 = *album == 0
+                       ? g_strdup(_("All tracks"))
+                       : utf8_to_locale(album);
                g_snprintf(str, size,  _("Artist: %s - %s"), s1, s2);
+               g_free(s1);
+               g_free(s2);
                break;
        }
-       g_free(s1);
-       g_free(s2);
        return str;
 }