[project @ 2006-01-07 13:12:58 by jmb]

Fix duplication of currently selected theme in theme_descriptor list

svn path=/import/netsurf/; revision=2012
This commit is contained in:
John Mark Bell 2006-01-07 13:12:58 +00:00
parent 07d4f5c57b
commit 5f160daacb

View File

@ -176,13 +176,18 @@ struct theme_descriptor *ro_gui_theme_get_available(void) {
struct theme_descriptor *test;
char pathname[256];
/* close any descriptors we've got so far */
/* close any descriptors we've got so far
* _except_ the current theme */
ro_gui_theme_free(theme_descriptors);
assert(theme_descriptors == theme_current);
if (strcmp(theme_current->name, "Aletheia") != 0) {
/* add our default 'Aletheia' theme */
snprintf(pathname, 256, "%s.Resources", NETSURF_DIR);
pathname[255] = '\0';
ro_gui_theme_add_descriptor(pathname, "Aletheia");
}
/* scan our choices directory */
snprintf(pathname, 256, "%s%s", THEME_PATH_R, THEME_LEAFNAME);
@ -212,6 +217,7 @@ struct theme_descriptor *ro_gui_theme_get_available(void) {
while (theme_descriptors->previous)
theme_descriptors = theme_descriptors->previous;
}
return theme_descriptors;
}
@ -320,6 +326,13 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) {
current->filename = filename;
current->leafname = current->filename + strlen(folder) + 1;
if (strcmp(current->name, theme_current->name) == 0) {
/* Don't add if this theme matches the current one */
free(current->filename);
free(current);
return false;
}
/* link in our new descriptor at the head*/
if (theme_descriptors) {
current->next = theme_descriptors;