From: Max Kellermann Date: Wed, 30 Sep 2009 17:56:06 +0000 (+0200) Subject: mpdclient: mpdclient_filelist_get() returns NULL on error X-Git-Tag: release-0.16~271 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=422c8a8b990f7d55c7594626763146386b82dbc7;p=ncmpc.git mpdclient: mpdclient_filelist_get() returns NULL on error Don't artificially return an empty list when an error occurs. Also don't insert the dummy ".." entry in mpdclient_filelist_get(), screen_file.c should do this. --- diff --git a/src/mpdclient.c b/src/mpdclient.c index e331544..2d65985 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -689,15 +689,14 @@ mpdclient_filelist_get(struct mpdclient *c, const gchar *path) mpd_send_list_meta(c->connection, path); filelist = filelist_new(); - if (path && path[0] && strcmp(path, "/")) - /* add a dummy entry for ./.. */ - filelist_append(filelist, NULL); while ((entity = mpd_recv_entity(c->connection)) != NULL) filelist_append(filelist, entity); - /* If there's an error, ignore it. We'll return an empty filelist. */ - mpdclient_finish_command(c); + if (mpdclient_finish_command(c)) { + filelist_free(filelist); + return NULL; + } filelist_sort_dir_play(filelist, compare_filelistentry); diff --git a/src/screen_file.c b/src/screen_file.c index 7805210..31af84d 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -64,6 +64,12 @@ file_reload(struct mpdclient *c) filelist_free(browser.filelist); browser.filelist = mpdclient_filelist_get(c, current_path); + if (browser.filelist == NULL) + browser.filelist = filelist_new(); + + if (*current_path != 0) + /* add a dummy entry for ./.. */ + filelist_prepend(browser.filelist, NULL); } /* the db has changed -> update the filelist */ @@ -289,7 +295,8 @@ static void browse_open(G_GNUC_UNUSED struct mpdclient *c) { if (browser.filelist == NULL) { - browser.filelist = mpdclient_filelist_get(c, ""); + file_reload(c); + #ifndef NCMPC_MINI mpdclient_install_playlist_callback(c, playlist_changed_callback); #endif