- Status Closed
- Percent Complete
- Task Type Bugs
- Category Plugins
- Assigned To No-one
- Operating System All players
- Severity Medium
- Priority Very Low
- Reported Version
- Due in Version Undecided
-
Due Date
Undecided
- Votes
- Private
FS#5658 - Text viewer hangs when first character is whitespace
The text viewer will hang if the first character of the text file is whitespace (space, return, tab, etc) and requires a hard reset. This started with the changes made in version 1.37 of plugins/viewer.c and probably only affects HAVE_LCD_BITMAP targets. I've traced the bug:
plugin_start() > viewer_load_settings() > init_need_scrollbar() > viewer_draw(-1) > endless loop at line 698
The bug appears to be because draw_columns is not set until after the call to viewer_draw(-1) in init_need_scrollbar. However, this variable is used in crap_at_width() which is needed in viewer_draw. With draw_columns=0, crop_at_width never advances to the next character and this screws up find_next_line().
As far as I can tell, for a text file with a non-whitespace first character (one that will not hang), viewer_draw(-1) only really "draws" the first character in the text file since crop_at_width() and find_next_line() never advance the string pointer. However, when the first character is whitespace, find_next_line() does advance because of extra checks for whitespace, but crop_at_width() does not. This causes the endless loop at line 698.
The simple solution, that does work, is to set draw_columns in viewer_init():
— viewer-1.39.c 2006-07-13 11:45:53.566535800 -0400
+++ viewer.c 2006-07-13 13:51:43.129035800 -0400
@@ -942,7 +942,7 @@
pf = rb->font_get(FONT_UI);
display_lines = LCD_HEIGHT / pf->height;
- display_columns = LCD_WIDTH;
+ draw_columns = display_columns = LCD_WIDTH;
#else
/* REAL fixed pitch :) all chars use up 1 cell */ display_lines = 2;
However, since revision 1.11 (over 14 months ago), draw_columns is not set until after viewer_draw(-1) in init_need_scrollbar (for HAVE_LCD_BITMAP targets); so maybe I'm missing the intended purpose of this action. Someone familiar with the viewer.c should review this and determine if this is the proper fix or if the bug lies else where.
2006-07-15 13:54
Reason for closing: Accepted
Additional comments about closing: Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407
I\'m not sure either but it fixes
the crash and seems to work ok
otherwise.
Loading...
Available keyboard shortcuts
- Alt + ⇧ Shift + l Login Dialog / Logout
- Alt + ⇧ Shift + a Add new task
- Alt + ⇧ Shift + m My searches
- Alt + ⇧ Shift + t focus taskid search
Tasklist
- o open selected task
- j move cursor down
- k move cursor up
Task Details
- n Next task
- p Previous task
- Alt + ⇧ Shift + e ↵ Enter Edit this task
- Alt + ⇧ Shift + w watch task
- Alt + ⇧ Shift + y Close Task
Task Editing
- Alt + ⇧ Shift + s save task
I just noticed this is also reported in http://www.rockbox.org/tracker/task/5434.
even after trying your fix I can still easily crash the viewer.
I think the code needs a more thorough check-up
EDIT: bah, crashing not easily reproducable :(