Mercurial > pidgin.yaz
changeset 13586:0cc7773b1d87
[gaim-migrate @ 15971]
Don't load invalid smiley themes (i.e. themes missing the Name, Description or Author lines). I noticed that gtkprefs were being initialized twice, so that is fixed too (it took me forever to figure out why the callback was being called twice).
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 06 Apr 2006 02:03:20 +0000 |
parents | ffb12e85473f |
children | bfda68675f7b |
files | src/gtkmain.c src/gtkthemes.c |
diffstat | 2 files changed, 74 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkmain.c Wed Apr 05 02:10:39 2006 +0000 +++ b/src/gtkmain.c Thu Apr 06 02:03:20 2006 +0000 @@ -248,7 +248,6 @@ #endif gaim_gtk_stock_init(); - gaim_gtk_prefs_init(); gaim_gtk_account_init(); gaim_gtk_connection_init(); gaim_gtk_blist_init(); @@ -506,11 +505,11 @@ "%scontactinfo.php\n"), GAIM_WEBSITE, GAIM_WEBSITE, GAIM_WEBSITE ); - + /* we have to convert the message (UTF-8 to console charset) early because after a segmentation fault it's not a good practice to allocate memory */ - segfault_message = g_locale_from_utf8(segfault_message_tmp, + segfault_message = g_locale_from_utf8(segfault_message_tmp, -1, NULL, NULL, &error); if (segfault_message != NULL) { g_free(segfault_message_tmp);
--- a/src/gtkthemes.c Wed Apr 05 02:10:39 2006 +0000 +++ b/src/gtkthemes.c Thu Apr 06 02:03:20 2006 +0000 @@ -72,6 +72,7 @@ struct smiley_list *list = NULL; GSList *lst = smiley_themes; char *dirname; + gboolean new_theme = FALSE; if (!f) return; @@ -86,40 +87,16 @@ } if (!theme) { + new_theme = TRUE; theme = g_new0(struct smiley_theme, 1); theme->path = g_strdup(file); - smiley_themes = g_slist_append(smiley_themes, theme); + } else if (theme == current_smiley_theme) { + /* Don't reload the theme if it is already loaded */ + fclose(f); + return; } dirname = g_path_get_dirname(file); - if (load) { - if (current_smiley_theme) { - GSList *already_freed = NULL; - struct smiley_list *wer = current_smiley_theme->list, *wer2; - while (wer) { - while (wer->smileys) { - GtkIMHtmlSmiley *uio = wer->smileys->data; - if (uio->icon) - g_object_unref(uio->icon); - if (!g_slist_find(already_freed, uio->file)) { - g_free(uio->file); - already_freed = g_slist_append(already_freed, uio->file); - } - g_free(uio->smile); - g_free(uio); - wer->smileys=g_slist_remove(wer->smileys, uio); - } - wer2 = wer->next; - g_free(wer->sml); - g_free(wer); - wer = wer2; - } - current_smiley_theme->list = NULL; - g_slist_free(already_freed); - } - current_smiley_theme = theme; - } - while (!feof(f)) { if (!fgets(buf, sizeof(buf), f)) { @@ -195,9 +172,75 @@ } } + g_free(dirname); + fclose(f); + + if (!theme->name || !theme->desc || !theme->author) { + GSList *already_freed = NULL; + struct smiley_list *wer = theme->list, *wer2; + + gaim_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file); + + while (wer) { + while (wer->smileys) { + GtkIMHtmlSmiley *uio = wer->smileys->data; + if (uio->icon) + g_object_unref(uio->icon); + if (!g_slist_find(already_freed, uio->file)) { + g_free(uio->file); + already_freed = g_slist_append(already_freed, uio->file); + } + g_free(uio->smile); + g_free(uio); + wer->smileys = g_slist_remove(wer->smileys, uio); + } + wer2 = wer->next; + g_free(wer->sml); + g_free(wer); + wer = wer2; + } + theme->list = NULL; + g_slist_free(already_freed); + + g_free(theme->path); + g_free(theme); + + return; + } + + if (new_theme) { + smiley_themes = g_slist_append(smiley_themes, theme); + } + if (load) { GList *cnv; + if (current_smiley_theme) { + GSList *already_freed = NULL; + struct smiley_list *wer = current_smiley_theme->list, *wer2; + while (wer) { + while (wer->smileys) { + GtkIMHtmlSmiley *uio = wer->smileys->data; + if (uio->icon) + g_object_unref(uio->icon); + if (!g_slist_find(already_freed, uio->file)) { + g_free(uio->file); + already_freed = g_slist_append(already_freed, uio->file); + } + g_free(uio->smile); + g_free(uio); + wer->smileys = g_slist_remove(wer->smileys, uio); + } + wer2 = wer->next; + g_free(wer->sml); + g_free(wer); + wer = wer2; + } + current_smiley_theme->list = NULL; + g_slist_free(already_freed); + } + current_smiley_theme = theme; + for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { GaimConversation *conv = cnv->data; @@ -207,9 +250,6 @@ } } } - - g_free(dirname); - fclose(f); } void gaim_gtkthemes_smiley_theme_probe()