[MPlayer-cvslog] r35607 - trunk/gui/interface.c
ib
subversion at mplayerhq.hu
Wed Dec 5 13:26:32 CET 2012
Author: ib
Date: Wed Dec 5 13:26:32 2012
New Revision: 35607
Log:
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.
Modified:
trunk/gui/interface.c
Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c Wed Dec 5 13:08:12 2012 (r35606)
+++ trunk/gui/interface.c Wed Dec 5 13:26:32 2012 (r35607)
@@ -855,10 +855,15 @@ int gui(int what, void *data)
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 @@ int guiPlaylist(int what, play_tree_t *p
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 @@ int guiPlaylist(int what, play_tree_t *p
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 @@ int guiPlaylist(int what, play_tree_t *p
break;
}
+ pt_iter_destroy(&pt_iter);
+
return added;
}
More information about the MPlayer-cvslog
mailing list