From: Max Kellermann Date: Sat, 17 Oct 2009 21:54:58 +0000 (+0200) Subject: screen_file: always set new list_window length X-Git-Tag: release-0.16~99 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6d0a673ceea6d7e31adf4f77ec177088e4a47308;p=ncmpc.git screen_file: always set new list_window length screen_file_reload() did not update the list_window length if it was not connected. This led to an assertion failure. --- diff --git a/src/screen_file.c b/src/screen_file.c index c4fa817..1387cee 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -52,31 +52,36 @@ screen_file_repaint(void) } static void -screen_file_reload(struct mpdclient *c) +screen_file_load_list(struct mpdclient *c, struct filelist *filelist) { struct mpd_connection *connection; - if (browser.filelist != NULL) - filelist_free(browser.filelist); - - browser.filelist = filelist_new(); - if (*current_path != 0) - /* add a dummy entry for ./.. */ - filelist_append(browser.filelist, NULL); - if (!mpdclient_is_connected(c)) return; connection = mpdclient_get_connection(c); mpd_send_list_meta(connection, current_path); - filelist_recv(browser.filelist, connection); + filelist_recv(filelist, connection); if (mpd_response_finish(connection)) - filelist_sort_dir_play(browser.filelist, - compare_filelist_entry_path); + filelist_sort_dir_play(filelist, compare_filelist_entry_path); else mpdclient_handle_error(c); +} + +static void +screen_file_reload(struct mpdclient *c) +{ + if (browser.filelist != NULL) + filelist_free(browser.filelist); + + browser.filelist = filelist_new(); + if (*current_path != 0) + /* add a dummy entry for ./.. */ + filelist_append(browser.filelist, NULL); + + screen_file_load_list(c, browser.filelist); list_window_set_length(browser.lw, filelist_length(browser.filelist));