Mercurial > mplayer.hg
changeset 35513:a24abc593a88
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.
author | ib |
---|---|
date | Wed, 05 Dec 2012 12:26:32 +0000 |
parents | ce2cda8acb4e |
children | a3ca6d31b29f |
files | gui/interface.c |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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; }