From ce24c36360d78b6fe6360bfe10d863fd1b1e19b8 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Sun, 12 Aug 2007 02:10:45 +0000 Subject: [PATCH] Change the way the MAX_FILETYPES define works. It now allocates enough filetype icons as it needed last boot + 8, this means we should never have to edit the define again. If you get the "filetypes array full" splash, do a clean reboot and it shuold go away. if it doesnt make sure you file a bug report and let us know you did reboot and it stayed there... it means that define does actually need increeasing. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14287 a1c6a512-1295-4272-9138-f99709370657 --- apps/filetypes.c | 62 +++++++++++++++++++++++++++++++--------------------- apps/settings.h | 8 +++++++ apps/settings_list.c | 1 + 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/apps/filetypes.c b/apps/filetypes.c index 785a317a7..1e7224a4e 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -41,20 +41,12 @@ #include "icons.h" #include "logf.h" -/* max filetypes (plugins & icons stored here) */ -#if CONFIG_CODEC == SWCODEC -#define MAX_FILETYPES 80 -#else -#define MAX_FILETYPES 48 -#endif - /* a table for the know file types */ const struct filetype inbuilt_filetypes[] = { { "mp3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "mp2", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "mpa", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, #if CONFIG_CODEC == SWCODEC - /* Temporary hack to allow playlist creation */ { "mp1", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "ogg", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "wma", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, @@ -104,7 +96,7 @@ const struct filetype inbuilt_filetypes[] = { { "cue", FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET }, #ifdef BOOTFILE_EXT { BOOTFILE_EXT, FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ }, -#endif /* #ifndef SIMULATOR */ +#endif /* #ifndef BOOTFILE_EXT */ }; void tree_get_filetypes(const struct filetype** types, int* count) @@ -123,14 +115,14 @@ struct file_type { char* plugin; /* Which plugin to use, NULL if unknown, or builtin */ char* extension; /* NULL for none */ }; -static struct file_type filetypes[MAX_FILETYPES]; -static int custom_filetype_icons[MAX_FILETYPES]; +static struct file_type *filetypes; +static int *custom_filetype_icons; static bool custom_icons_loaded = false; #ifdef HAVE_LCD_COLOR -static int custom_colors[MAX_FILETYPES+1]; +static int *custom_colors; #endif -static int filetype_count = 0; static unsigned char heighest_attr = 0; +static int max_types = 0, filetype_count; static char *filetypes_strdup(char* string) { @@ -150,7 +142,10 @@ void read_color_theme_file(void) { int fd; char *ext, *color; int i; - for (i = 0; i < MAX_FILETYPES+1; i++) { + + if (max_types == 0) + return; + for (i = 0; i < filetype_count+1; i++) { custom_colors[i] = -1; } snprintf(buffer, MAX_PATH, "%s/%s.colours", THEME_DIR, @@ -169,7 +164,7 @@ void read_color_theme_file(void) { } if (!strcasecmp(ext, "???")) { - custom_colors[MAX_FILETYPES] = hex_to_rgb(color); + custom_colors[filetype_count] = hex_to_rgb(color); continue; } for (i=1; i>8; + filetypes[filetype_count].attr = inbuilt_filetypes[i].tree_attr>>8; if (filetypes[filetype_count].attr > heighest_attr) heighest_attr = filetypes[filetype_count].attr; - filetypes[filetype_count].icon = inbuilt_filetypes[i].icon; + filetypes[filetype_count].icon = inbuilt_filetypes[i].icon; filetype_count++; } } @@ -291,14 +302,15 @@ static void read_config(char* config_file) int fd = open(config_file, O_RDONLY); if (fd < 0) return; - /* config file is in the for + /* config file is in the form ,, ignore line if either of the first two are missing */ while (read_line(fd, line, 64) > 0) { - if (filetype_count >= MAX_FILETYPES) + if (filetype_count >= max_types) { gui_syncsplash(HZ, ID2P(LANG_FILETYPES_FULL)); + global_status.filetype_count = 0; /* make plenty of room for next reboot */ break; } rm_whitespaces(line); @@ -347,7 +359,7 @@ int filetype_get_attr(const char* file) if (!extension) return 0; extension++; - for (i=0; i