From d827554bd4ac6761bb757f34acef69dfeab0ab0b Mon Sep 17 00:00:00 2001 From: uchida Date: Tue, 8 Jun 2010 10:34:13 +0000 Subject: [PATCH] text viewer: 1) fix uisim abends when fonts list is displayed. 2) simplify the logic to change font. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26685 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/text_viewer/tv_menu.c | 4 +++- apps/plugins/text_viewer/tv_window.c | 19 ++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c index d9b534349..eb9278238 100644 --- a/apps/plugins/text_viewer/tv_menu.c +++ b/apps/plugins/text_viewer/tv_menu.c @@ -254,6 +254,7 @@ static bool tv_font_setting(void) int new_font = 0; int old_font; bool res; + unsigned char font_path[MAX_PATH]; struct tree_context *tree; struct tree_context backup; @@ -266,7 +267,8 @@ static bool tv_font_setting(void) rb->strlcat(backup.currdir, "/", MAX_PATH); rb->strlcat(backup.currdir, dc[tree->selected_item].name, MAX_PATH); tree->dirfilter = &dirfilter; - rb->set_current_file(FONT_DIR"/"); + rb->snprintf(font_path, MAX_PATH, "%s/", FONT_DIR); + rb->set_current_file(font_path); count = tree->filesindir; struct opt_items names[count]; diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c index 676aff40a..36fbb9268 100644 --- a/apps/plugins/text_viewer/tv_window.c +++ b/apps/plugins/text_viewer/tv_window.c @@ -278,11 +278,11 @@ bool tv_traverse_lines(void) static void tv_change_preferences(const struct tv_preferences *oldp) { #ifdef HAVE_LCD_BITMAP - static bool is_executing = false; + static bool font_changing = false; const unsigned char *font_str; - is_executing = true; - font_str = oldp? oldp->font_name: rb->global_settings->font_file; + font_str = (oldp && !font_changing)? oldp->font_name : rb->global_settings->font_file; + font_changing = true; /* change font */ if (rb->strcmp(font_str, prefs->font_name)) @@ -291,25 +291,22 @@ static void tv_change_preferences(const struct tv_preferences *oldp) { struct tv_preferences new_prefs = *prefs; - if (!tv_set_font(font_str) && oldp != NULL) - { - font_str = rb->global_settings->font_file; - tv_set_font(font_str); - } - rb->strlcpy(new_prefs.font_name, font_str, MAX_PATH); tv_set_preferences(&new_prefs); } } + else if (!oldp || font_changing) + tv_set_font(font_str); /* calculates display lines */ tv_check_header_and_footer(); display_lines = tv_calc_display_lines(); - if (!is_executing) + /* if font_changing == false, the remaining processes need not be executed. */ + if (!font_changing) return; - is_executing = false; + font_changing = false; #else (void)oldp; -- 2.11.4.GIT