From 57e928f9f3c78aa2aa4dbcbd0fb90151566f7cb0 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Mon, 14 Apr 2003 07:53:58 +0000 Subject: Fixed the garbled display when deleting the last file in a directory (bug #680811) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3549 a1c6a512-1295-4272-9138-f99709370657 --- apps/tree.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'apps') diff --git a/apps/tree.c b/apps/tree.c index b50dd5c826..5a8618babb 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -380,6 +380,21 @@ static int showdir(char *path, int start) dirstart = start; } + /* The cursor might point to an invalid line, for example if someone + deleted the last file in the dir */ + if(filesindir) + { + while(start + dircursor >= filesindir) + { + if(start) + start--; + else + if(dircursor) + dircursor--; + } + dirstart = start; + } + #ifdef HAVE_LCD_CHARCELLS lcd_stop_scroll(); lcd_double_height(false); @@ -1119,6 +1134,7 @@ bool dirbrowse(char *root) if (restore || reload_dir) { /* restore display */ + /* We need to adjust if the number of lines on screen have changed because of a status bar change */ if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) { -- cgit v1.2.3