Code

screen_file: always set new list_window length
authorMax Kellermann <max@duempel.org>
Sat, 17 Oct 2009 21:54:58 +0000 (23:54 +0200)
committerMax Kellermann <max@duempel.org>
Sat, 17 Oct 2009 21:54:58 +0000 (23:54 +0200)
screen_file_reload() did not update the list_window length if it was
not connected.  This led to an assertion failure.

src/screen_file.c

index c4fa8171ab2e371b5b74c11cbf016a280ccd614d..1387cee519fc066f0bc96bf0b02d8627de5d187c 100644 (file)
@@ -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));