Code

screen_artist: check connection!=NULL in load_song_list()
[ncmpc.git] / src / screen_artist.c
index 847bed045286f3a73c3dc3d0d193ded91751a6f5..a3bda330ef9fb22877fe6ce3347418d46837cfe1 100644 (file)
@@ -60,8 +60,7 @@ compare_utf8(gconstpointer s1, gconstpointer s2)
 
 /* list_window callback */
 static const char *
-screen_artist_lw_callback(unsigned idx, G_GNUC_UNUSED bool *highlight,
-                         G_GNUC_UNUSED char** sc, G_GNUC_UNUSED void *data)
+screen_artist_lw_callback(unsigned idx, void *data)
 {
        GPtrArray *list = data;
        static char buf[BUFSIZE];
@@ -216,22 +215,24 @@ load_song_list(struct mpdclient *c)
        assert(album != NULL);
        assert(browser.filelist == NULL);
 
-       mpd_search_db_songs(connection, true);
-       mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT,
-                                     MPD_TAG_ARTIST, artist);
-       if (album[0] != 0)
-               mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT,
-                                             MPD_TAG_ALBUM, album);
-       mpd_search_commit(connection);
-
        browser.filelist = filelist_new();
        /* add a dummy entry for ".." */
        filelist_append(browser.filelist, NULL);
 
-       filelist_recv(browser.filelist, connection);
+       if (connection != NULL) {
+               mpd_search_db_songs(connection, true);
+               mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT,
+                                             MPD_TAG_ARTIST, artist);
+               if (album[0] != 0)
+                       mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT,
+                                                     MPD_TAG_ALBUM, album);
+               mpd_search_commit(connection);
+
+               filelist_recv(browser.filelist, connection);
 
-       if (!mpd_response_finish(connection))
-               mpdclient_handle_error(c);
+               if (!mpd_response_finish(connection))
+                       mpdclient_handle_error(c);
+       }
 
 #ifndef NCMPC_MINI
        /* fix highlights */