# HG changeset patch # User ib # Date 1354710392 0 # Node ID a24abc593a88d2f37240c8bffcc1ea3687560b0f # Parent ce2cda8acb4e1738bacf0c06da3dd6ab5e51adec Revise guiPlaylist() concerning pt_iter. Remove unnecessary initialization, move pt_iter_create() to the beginning and return in case of error (which won't unnecessarily delete an existing playlist) and add missing pt_iter_destroy() for GUI_PLAYLIST_INIT by moving it to the end. diff -r ce2cda8acb4e -r a24abc593a88 gui/interface.c --- a/gui/interface.c Wed Dec 05 12:08:12 2012 +0000 +++ b/gui/interface.c Wed Dec 05 12:26:32 2012 +0000 @@ -855,10 +855,15 @@ int guiPlaylist(int what, play_tree_t *playtree, m_config_t *config, int enqueue) { - play_tree_iter_t *pt_iter = NULL; + play_tree_iter_t *pt_iter; int added = False; plItem *curr; + pt_iter = pt_iter_create(&playtree, config); + + if (!pt_iter) + return False; + switch (what) { // This function imports the initial playtree (based on cmd-line files) // into the gui playlist by either: @@ -869,12 +874,10 @@ if (!enqueue) listMgr(PLAYLIST_DELETE, 0); // delete playlist before "appending" - if ((pt_iter = pt_iter_create(&playtree, config))) { while ((filename = pt_iter_get_next_file(pt_iter)) != NULL) /* add it to end of list */ if (add_to_gui_playlist(filename, PLAYLIST_ITEM_APPEND)) added = True; - } uiCurr(); // update filename guiInfo.PlaylistNext = True; @@ -896,15 +899,11 @@ curr = (plItem *)listMgr(PLAYLIST_ITEM_GET_CURR, 0); - if ((pt_iter = pt_iter_create(&playtree, config))) { while ((filename = pt_iter_get_next_file(pt_iter)) != NULL) /* insert it into the list and set plCurrent=new item */ if (add_to_gui_playlist(filename, PLAYLIST_ITEM_INSERT)) added = True; - pt_iter_destroy(&pt_iter); - } - if (curr) listMgr(PLAYLIST_ITEM_SET_CURR, curr); else @@ -918,6 +917,8 @@ break; } + pt_iter_destroy(&pt_iter); + return added; }