From 20c69d19b2e86db338d0b33d75fadee9c64b3a94 Mon Sep 17 00:00:00 2001 From: gevaerts Date: Sun, 10 Oct 2010 13:17:39 +0000 Subject: [PATCH] Add a "early_usb" argument to gui_usb_screen_run(), and don't do skin unloading/reloading in gui_usb_screen_run() in the early usb case. Fixes the crash part of FS#11589 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28229 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_render.c | 16 ++++++++-------- apps/gui/usb_screen.c | 23 +++++++++++++++-------- apps/gui/usb_screen.h | 4 ++-- apps/main.c | 4 ++-- apps/misc.c | 2 +- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 304ebf140..17ecce78d 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c @@ -78,7 +78,7 @@ static void skin_render_playlistviewer(struct playlistviewer* viewer, unsigned long refresh_type); #endif -static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, +static __attribute__((noinline)) bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, struct skin_element *element, struct viewport* vp) { #ifndef HAVE_LCD_BITMAP @@ -234,7 +234,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, -static void do_tags_in_hidden_conditional(struct skin_element* branch, +static __attribute__((noinline)) void do_tags_in_hidden_conditional(struct skin_element* branch, struct skin_draw_info *info) { #ifdef HAVE_LCD_BITMAP @@ -328,7 +328,7 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch, } } -static void fix_line_alignment(struct skin_draw_info *info, struct skin_element *element) +static __attribute__((noinline)) void fix_line_alignment(struct skin_draw_info *info, struct skin_element *element) { struct align_pos *align = &info->align; char *cur_pos = info->cur_align_start + strlen(info->cur_align_start); @@ -371,7 +371,7 @@ static void fix_line_alignment(struct skin_draw_info *info, struct skin_element } /* Draw a LINE element onto the display */ -static bool skin_render_line(struct skin_element* line, struct skin_draw_info *info) +static __attribute__((noinline)) bool skin_render_line(struct skin_element* line, struct skin_draw_info *info) { bool needs_update = false; int last_value, value; @@ -478,7 +478,7 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i return needs_update; } -static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) +static __attribute__((noinline)) int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) { struct skin_element *element=line; struct wps_token *token; @@ -514,7 +514,7 @@ static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) return retval; } -bool skin_render_alternator(struct skin_element* element, struct skin_draw_info *info) +bool __attribute__((noinline)) skin_render_alternator(struct skin_element* element, struct skin_draw_info *info) { bool changed_lines = false; struct line_alternator *alternator = (struct line_alternator*)element->data; @@ -570,7 +570,7 @@ bool skin_render_alternator(struct skin_element* element, struct skin_draw_info return changed_lines || ret; } -static void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, +static __attribute__((noinline)) void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, struct skin_viewport* skin_viewport, unsigned long refresh_type) { struct screen *display = gwps->display; @@ -715,7 +715,7 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode) } #ifdef HAVE_LCD_BITMAP -static void skin_render_playlistviewer(struct playlistviewer* viewer, +static __attribute__((noinline)) void skin_render_playlistviewer(struct playlistviewer* viewer, struct gui_wps *gwps, struct skin_viewport* skin_viewport, unsigned long refresh_type) diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c index 00e128be7..78f61f5cc 100644 --- a/apps/gui/usb_screen.c +++ b/apps/gui/usb_screen.c @@ -241,7 +241,7 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) } } -void gui_usb_screen_run(void) +void gui_usb_screen_run(bool early_usb) { int i; struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS]; @@ -262,14 +262,18 @@ void gui_usb_screen_run(void) usb_keypad_mode = global_settings.usb_keypad_mode; #endif - /* The font system leaves the .fnt fd's open, so we need for force close them all */ + if(!early_usb) + { + /* The font system leaves the .fnt fd's open, so we need for force close them all */ #ifdef HAVE_LCD_BITMAP - font_reset(NULL); + font_reset(NULL); #ifdef HAVE_REMOTE_LCD - font_load_remoteui(NULL); + font_load_remoteui(NULL); #endif - skin_font_init(); /* unload all the skin fonts */ + skin_font_init(); /* unload all the skin fonts */ #endif + } + FOR_NB_SCREENS(i) { struct screen *screen = &screens[i]; @@ -324,9 +328,12 @@ void gui_usb_screen_run(void) status_set_usb(false); #endif /* HAVE_LCD_CHARCELLS */ #ifdef HAVE_LCD_BITMAP - /* Not pretty, reload all settings so fonts are loaded again correctly */ - settings_apply(true); - settings_apply_skins(); + if(!early_usb) + { + /* Not pretty, reload all settings so fonts are loaded again correctly */ + settings_apply(true); + settings_apply_skins(); + } #endif FOR_NB_SCREENS(i) diff --git a/apps/gui/usb_screen.h b/apps/gui/usb_screen.h index 84d92d24f..24075ae38 100644 --- a/apps/gui/usb_screen.h +++ b/apps/gui/usb_screen.h @@ -22,9 +22,9 @@ #define _USB_SCREEN_H_ #ifdef USB_NONE -static inline void gui_usb_screen_run(void) {} +static inline void gui_usb_screen_run(bool early_usb) {} #else -extern void gui_usb_screen_run(void); +extern void gui_usb_screen_run(bool early_usb); #endif #endif diff --git a/apps/main.c b/apps/main.c index 949790b05..950168d8e 100644 --- a/apps/main.c +++ b/apps/main.c @@ -573,7 +573,7 @@ static void init(void) (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED)) #endif { - gui_usb_screen_run(); + gui_usb_screen_run(true); mounted = true; /* mounting done @ end of USB mode */ } #ifdef HAVE_USB_POWER @@ -600,7 +600,7 @@ static void init(void) lcd_update(); while(button_get(true) != SYS_USB_CONNECTED) {}; - gui_usb_screen_run(); + gui_usb_screen_run(true); system_reboot(); } } diff --git a/apps/misc.c b/apps/misc.c index 4b89a5d4a..5f6df4648 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -547,7 +547,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame check_bootfile(false); /* gets initial size */ #endif #endif - gui_usb_screen_run(); + gui_usb_screen_run(false); #ifdef BOOTFILE #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) check_bootfile(true); -- 2.11.4.GIT