From 188f025f519bc99e51a20ea842df9898a461ca6d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 21 Jul 2024 01:45:25 -0400 Subject: [Bug Fix] Data Abort on Usb Unplug, database browser ran on USB dc current_lists holds a pointer to whatver the current list is only problem is when in one of the function type menus like the plugin viewer, playlist viewer, shortcut menu probably a few others on usb unplug current_lists holds stale data and updates the list however the data has already been freed when the function returned the issue with db browser was a return of true from dirbrowse() which was the value 1 which is the enum for GO_TO_DBBROWSER Change-Id: I7349dfab2752e11f8e746925501740e959851cd5 --- apps/gui/list.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/list.c b/apps/gui/list.c index 85046ead54..5368636896 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -51,6 +51,7 @@ void list_draw(struct screen *display, struct gui_synclist *list); static long last_dirty_tick; static struct viewport parent[NB_SCREENS]; +static struct gui_synclist *current_lists; static bool list_is_dirty(struct gui_synclist *list) { @@ -59,8 +60,12 @@ static bool list_is_dirty(struct gui_synclist *list) static void list_force_reinit(unsigned short id, void *param, void *last_dirty_tick) { - (void)id; (void)param; + if (id == SYS_EVENT_USB_INSERTED) /* Disable the skin redraw callback -- Data may not be valid after USB unplug*/ + { + current_lists = NULL; + return; + } *(int *)last_dirty_tick = current_tick; } @@ -68,6 +73,7 @@ void list_init(void) { last_dirty_tick = current_tick; add_event_ex(GUI_EVENT_THEME_CHANGED, false, list_force_reinit, &last_dirty_tick); + add_event_ex(SYS_EVENT_USB_INSERTED, false, list_force_reinit, NULL); } static void list_init_viewports(struct gui_synclist *list) @@ -590,7 +596,6 @@ bool gui_synclist_keyclick_callback(int action, void* data) * if something is using the list UI they *must* be calling those * two functions in the correct order or the list wont work. */ -static struct gui_synclist *current_lists; static bool ui_update_event_registered = false; static void _lists_uiviewport_update_callback(unsigned short id, void *data) { -- cgit v1.2.3