summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-07-21 11:53:25 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2024-07-22 10:27:24 -0400
commit7720b0c4e4383670a64595bb9d199c5e2dbe6651 (patch)
tree208fafcc4bf94b5d387b6517fa244ccf56dc8a74
parent2bb9323de8e4edc0a04ccf7ccf61e3026b5ef847 (diff)
downloadrockbox-7720b0c4e4.tar.gz
rockbox-7720b0c4e4.zip
[Bugfix] crashes on usb unplug, extra text on USB screen, viewportmgr ovfl on sim
make _lists_uiviewport_update_callback a oneshot and reset it each call of list_do_action_timeout() block multiple runs of gui_usb_screen_run() in the sim Change-Id: I0c0429c42622c82bcf481ad13efdc47e9055a1bb
-rw-r--r--apps/gui/list.c31
-rw-r--r--apps/gui/usb_screen.c11
2 files changed, 23 insertions, 19 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 5368636896..256cf45c40 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -60,12 +60,8 @@ 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;
}
@@ -73,7 +69,6 @@ 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)
@@ -166,7 +161,6 @@ void gui_synclist_init(struct gui_synclist * gui_list,
gui_list->nb_items = 0;
gui_list->selected_item = 0;
gui_synclist_init_display_settings(gui_list);
-
#ifdef HAVE_TOUCHSCREEN
gui_list->y_pos = 0;
#endif
@@ -592,15 +586,19 @@ bool gui_synclist_keyclick_callback(int action, void* data)
* loop.
*
* The GUI_EVENT_NEED_UI_UPDATE event is registered for in list_do_action_timeout()
- * and unregistered in gui_synclict_do_button(). This is done because
- * if something is using the list UI they *must* be calling those
+ * as a oneshot and current_lists updated. later current_lists is set to NULL
+ * in gui_synclist_do_button() effectively disabling the callback.
+* This is done because if something is using the list UI they *must* be calling those
* two functions in the correct order or the list wont work.
*/
-static bool ui_update_event_registered = false;
-static void _lists_uiviewport_update_callback(unsigned short id, void *data)
+
+static void _lists_uiviewport_update_callback(unsigned short id,
+ void *data, void *userdata)
{
(void)id;
(void)data;
+ (void)userdata;
+
if (current_lists)
gui_synclist_draw(current_lists);
}
@@ -774,13 +772,8 @@ int list_do_action_timeout(struct gui_synclist *lists, int timeout)
/* Returns the lowest of timeout or the delay until a postponed
scheduled announcement is due (if any). */
{
- if (lists != current_lists)
- {
- if (!ui_update_event_registered)
- ui_update_event_registered =
- add_event(GUI_EVENT_NEED_UI_UPDATE, _lists_uiviewport_update_callback);
- current_lists = lists;
- }
+ add_event_ex(GUI_EVENT_NEED_UI_UPDATE, true, _lists_uiviewport_update_callback, NULL);
+ current_lists = lists;
if(lists->scheduled_talk_tick)
{
long delay = lists->scheduled_talk_tick -current_tick +1;
@@ -949,7 +942,9 @@ bool simplelist_show_list(struct simplelist_info *info)
old_line_count = simplelist_line_count;
}
else if(default_event_handler(action) == SYS_USB_CONNECTED)
+ {
return true;
+ }
}
talk_shutup();
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c
index fb59f820b6..8a3510ea15 100644
--- a/apps/gui/usb_screen.c
+++ b/apps/gui/usb_screen.c
@@ -243,7 +243,13 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
void gui_usb_screen_run(bool early_usb)
{
- (void) early_usb;
+#ifdef SIMULATOR /* the sim allows toggling USB fast enough to overflow viewportmanagers stack */
+ static bool in_usb_screen = false;
+ if (in_usb_screen)
+ return;
+ in_usb_screen = true;
+#endif
+
struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS];
#if defined HAVE_TOUCHSCREEN
enum touchscreen_mode old_mode = touchscreen_get_mode();
@@ -334,4 +340,7 @@ void gui_usb_screen_run(bool early_usb)
}
pop_current_activity();
+#ifdef SIMULATOR
+ in_usb_screen = false;
+#endif
}