diff options
author | William Wilgus <wilgus.william@gmail.com> | 2023-11-22 00:07:30 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2023-11-22 00:52:58 -0500 |
commit | 72c539d35e1853980de1d74e65acc9a22caa63f6 (patch) | |
tree | 34c70c631addcd7dac99c294a1316391ef3e22c8 /apps/tree.c | |
parent | 6e90bfe029fc69ad5a3b0e34b60b8a50f9105c2c (diff) | |
download | rockbox-72c539d35e1853980de1d74e65acc9a22caa63f6.tar.gz rockbox-72c539d35e1853980de1d74e65acc9a22caa63f6.zip |
[Bug_Fix] shortcut to directory in .link files caused crash
since the plugin browser is now closed when running plugins
rb->set_current_file() had no valid browser context and used 'random' memory
instead
also adds a way to discard levels so we can load the desired directory
instead of returning to the previous
https://forums.rockbox.org/index.php/topic,54694.0.html
Change-Id: I624246e56d42972bf6a1ce566a209b745de6f30b
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 22 |
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]; | |||
973 | static int backup_count = -1; | 980 | static int backup_count = -1; |
974 | int rockbox_browse(struct browse_context *browse) | 981 | int 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 */ |
1199 | void tree_flush(void) | 1217 | void 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 |