[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
This commit is contained in:
William Wilgus 2023-11-22 00:07:30 -05:00
parent 6e90bfe029
commit 72c539d35e
5 changed files with 83 additions and 13 deletions

View file

@ -287,12 +287,18 @@ static int compare(const void* p1, const void* p2)
/* load and sort directory into the tree's cache. returns NULL on failure. */
int ft_load(struct tree_context* c, const char* tempdir)
{
if (c->out_of_tree > 0) /* something else is loaded */
return 0;
int files_in_dir = 0;
int name_buffer_used = 0;
struct dirent *entry;
bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
DIR *dir;
if (!c->is_browsing)
c->browse = NULL;
if (tempdir)
dir = opendir(tempdir);
else
@ -760,6 +766,7 @@ int ft_enter(struct tree_context* c)
}
}
}
return rc;
}
@ -802,5 +809,7 @@ int ft_exit(struct tree_context* c)
if (exit_func)
rc = 3;
c->out_of_tree = 0;
return rc;
}