summaryrefslogtreecommitdiff
path: root/apps/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/apps/tree.c b/apps/tree.c
index 8fa5f168fd..ba4da816d1 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -608,6 +608,13 @@ void set_current_file(const char *path)
608 { 608 {
609 tc.selected_item = tree_get_file_position(lastfile); 609 tc.selected_item = tree_get_file_position(lastfile);
610 } 610 }
611
612 if (!tc.is_browsing && tc.out_of_tree == 0)
613 {
614 /* the browser is closed */
615 /* don't allow the previous items to overwrite what we just loaded */
616 tc.out_of_tree = tc.selected_item + 1;
617 }
611} 618}
612 619
613 620
@@ -652,7 +659,7 @@ static int dirbrowse(void)
652 return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */ 659 return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */
653 } 660 }
654 661
655 while(tc.browse) { 662 while(tc.browse && tc.is_browsing) {
656 bool restore = false; 663 bool restore = false;
657 if (tc.dirlevel < 0) 664 if (tc.dirlevel < 0)
658 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ 665 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
@@ -973,10 +980,18 @@ static struct tree_context backups[NUM_TC_BACKUP];
973static int backup_count = -1; 980static int backup_count = -1;
974int rockbox_browse(struct browse_context *browse) 981int rockbox_browse(struct browse_context *browse)
975{ 982{
983 tc.is_browsing = (browse != NULL);
976 static char current[MAX_PATH]; 984 static char current[MAX_PATH];
977 int ret_val = 0; 985 int ret_val = 0;
978 int dirfilter = browse->dirfilter; 986 int dirfilter = browse->dirfilter;
979 987
988 if (tc.out_of_tree > 0)
989 {
990 tc.selected_item = tc.out_of_tree - 1;
991 tc.out_of_tree = 0;
992 return ft_enter(&tc);
993 }
994
980 if (backup_count >= NUM_TC_BACKUP) 995 if (backup_count >= NUM_TC_BACKUP)
981 return GO_TO_PREVIOUS; 996 return GO_TO_PREVIOUS;
982 if (backup_count >= 0) 997 if (backup_count >= 0)
@@ -1031,6 +1046,9 @@ int rockbox_browse(struct browse_context *browse)
1031 backup_count--; 1046 backup_count--;
1032 if (backup_count >= 0) 1047 if (backup_count >= 0)
1033 tc = backups[backup_count]; 1048 tc = backups[backup_count];
1049
1050 tc.is_browsing = false;
1051
1034 return ret_val; 1052 return ret_val;
1035} 1053}
1036 1054
@@ -1198,7 +1216,7 @@ static int ft_play_filename(char *dir, char *file, int attr)
1198/* These two functions are called by the USB and shutdown handlers */ 1216/* These two functions are called by the USB and shutdown handlers */
1199void tree_flush(void) 1217void tree_flush(void)
1200{ 1218{
1201 tc.browse = NULL; /* clear browse to prevent reentry to a possibly missing file */ 1219 tc.is_browsing = false;/* clear browse to prevent reentry to a possibly missing file */
1202#ifdef HAVE_TAGCACHE 1220#ifdef HAVE_TAGCACHE
1203 tagcache_shutdown(); 1221 tagcache_shutdown();
1204#endif 1222#endif