diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-05-14 23:48:18 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-05-14 23:48:18 +0000 |
commit | eb8ceadc32dc5e5964609f86d9b8e063f435a4e0 (patch) | |
tree | 96b14e34e89ea7750eb0252ff6c5f852d3ffe1c5 /apps/tree.c | |
parent | 268f0b43376524b1e05e4d67f3e41a88356eea68 (diff) | |
download | rockbox-eb8ceadc32dc5e5964609f86d9b8e063f435a4e0.tar.gz rockbox-eb8ceadc32dc5e5964609f86d9b8e063f435a4e0.zip |
Bugfixes: (all) Don't try to build the directory list when showdir() returns -1. (hotswap) Handle the 'dir no longer valid' situation in all cases, not only when the file system change happens while browsing. Force this detection when returning from wps.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6472 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/apps/tree.c b/apps/tree.c index d713a2378b..12acdc8c70 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -283,7 +283,7 @@ static int showdir(void) | |||
283 | } | 283 | } |
284 | else { | 284 | else { |
285 | if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) { | 285 | if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) { |
286 | if (ft_load(&tc, NULL) < 0) | 286 | if (ft_load(&tc, NULL) < 0) |
287 | return -1; | 287 | return -1; |
288 | strcpy(lastdir, tc.currdir); | 288 | strcpy(lastdir, tc.currdir); |
289 | newdir = true; | 289 | newdir = true; |
@@ -1117,19 +1117,10 @@ static bool dirbrowse(void) | |||
1117 | 1117 | ||
1118 | #ifdef HAVE_HOTSWAP | 1118 | #ifdef HAVE_HOTSWAP |
1119 | case SYS_FS_CHANGED: | 1119 | case SYS_FS_CHANGED: |
1120 | if (!id3db) /* file browsing */ | 1120 | if (!id3db) |
1121 | { | 1121 | reload_dir = true; |
1122 | if (currdir[1]) /* not in the root */ | 1122 | /* The 'dir no longer valid' situation will be caught later |
1123 | { | 1123 | * by checking the showdir() result. */ |
1124 | DIR *dir = opendir(currdir); | ||
1125 | if (dir) /* path still valid */ | ||
1126 | { | ||
1127 | closedir(dir); | ||
1128 | break; /* don't reload the root */ | ||
1129 | } | ||
1130 | } | ||
1131 | reload_root = true; | ||
1132 | } | ||
1133 | break; | 1124 | break; |
1134 | #endif | 1125 | #endif |
1135 | 1126 | ||
@@ -1159,6 +1150,11 @@ static bool dirbrowse(void) | |||
1159 | lcd_stop_scroll(); | 1150 | lcd_stop_scroll(); |
1160 | if (wps_show() == SYS_USB_CONNECTED) | 1151 | if (wps_show() == SYS_USB_CONNECTED) |
1161 | reload_root = true; | 1152 | reload_root = true; |
1153 | #ifdef HAVE_HOTSWAP | ||
1154 | else | ||
1155 | if (!id3db) /* Try reload to catch 'no longer valid' case. */ | ||
1156 | reload_dir = true; | ||
1157 | #endif | ||
1162 | #ifdef HAVE_LCD_BITMAP | 1158 | #ifdef HAVE_LCD_BITMAP |
1163 | tree_max_on_screen = recalc_screen_height(); | 1159 | tree_max_on_screen = recalc_screen_height(); |
1164 | #endif | 1160 | #endif |
@@ -1167,6 +1163,9 @@ static bool dirbrowse(void) | |||
1167 | start_wps=false; | 1163 | start_wps=false; |
1168 | } | 1164 | } |
1169 | 1165 | ||
1166 | #ifdef HAVE_HOTSWAP | ||
1167 | check_rescan: | ||
1168 | #endif | ||
1170 | /* do we need to rescan dir? */ | 1169 | /* do we need to rescan dir? */ |
1171 | if (reload_dir || reload_root || | 1170 | if (reload_dir || reload_root || |
1172 | lastfilter != *tc.dirfilter || | 1171 | lastfilter != *tc.dirfilter || |
@@ -1217,6 +1216,14 @@ static bool dirbrowse(void) | |||
1217 | lcd_setfont(FONT_UI); | 1216 | lcd_setfont(FONT_UI); |
1218 | #endif | 1217 | #endif |
1219 | numentries = showdir(); | 1218 | numentries = showdir(); |
1219 | #ifdef HAVE_HOTSWAP | ||
1220 | if (currdir[1] && (numentries < 0)) | ||
1221 | { /* not in root and reload failed */ | ||
1222 | reload_root = true; /* try root */ | ||
1223 | reload_dir = false; | ||
1224 | goto check_rescan; | ||
1225 | } | ||
1226 | #endif | ||
1220 | update_all = true; | 1227 | update_all = true; |
1221 | put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true); | 1228 | put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true); |
1222 | 1229 | ||
@@ -1224,14 +1231,14 @@ static bool dirbrowse(void) | |||
1224 | reload_dir = false; | 1231 | reload_dir = false; |
1225 | } | 1232 | } |
1226 | 1233 | ||
1227 | if ( numentries && need_update) { | 1234 | if ( (numentries > 0) && need_update) { |
1228 | i = tc.dirstart+tc.dircursor; | 1235 | i = tc.dirstart+tc.dircursor; |
1229 | 1236 | ||
1230 | /* if MP3 filter is on, cut off the extension */ | 1237 | /* if MP3 filter is on, cut off the extension */ |
1231 | if(lasti!=i || restore) { | 1238 | if(lasti!=i || restore) { |
1232 | char* name; | 1239 | char* name; |
1233 | int attr = 0; | 1240 | int attr = 0; |
1234 | 1241 | ||
1235 | if (id3db) | 1242 | if (id3db) |
1236 | name = ((char**)tc.dircache)[lasti * tc.dentry_size]; | 1243 | name = ((char**)tc.dircache)[lasti * tc.dentry_size]; |
1237 | else { | 1244 | else { |