pidgin: 910949d9: Clarify load_smiley_theme a little. Refs...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Aug 2 01:41:09 EDT 2009


-----------------------------------------------------------------
Revision: 910949d93091afc24529b51807c9c4de3626c2df
Ancestor: 85ba052cd9c6d114ae61bebd086e1af59dd7f6ca
Author: darkrain42 at pidgin.im
Date: 2009-08-02T04:33:26
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/910949d93091afc24529b51807c9c4de3626c2df

Modified files:
        pidgin/gtkthemes.c

ChangeLog: 

Clarify load_smiley_theme a little. Refs #9822.

This wasn't actually leaking, the theme was either in smiley_themes
already or was added there, but I can see why the analysis tool was
confused.

-------------- next part --------------
============================================================
--- pidgin/gtkthemes.c	2b68e4edbf5cc62696680e01cb92eb578a828064
+++ pidgin/gtkthemes.c	3363485cb24f7bc51a9b83780d452673f909a534
@@ -229,7 +229,6 @@ void pidgin_themes_load_smiley_theme(con
 	struct smiley_list *list = NULL;
 	GSList *lst = smiley_themes;
 	char *dirname;
-	gboolean new_theme = FALSE;
 
 	if (!f)
 		return;
@@ -243,16 +242,18 @@ void pidgin_themes_load_smiley_theme(con
 		lst = lst->next;
 	}
 
-	if (!theme) {
-		new_theme = TRUE;
-		theme = g_new0(struct smiley_theme, 1);
-		theme->path = g_strdup(file);
-	} else if (theme == current_smiley_theme) {
+	if (theme == current_smiley_theme) {
 		/* Don't reload the theme if it is already loaded */
 		fclose(f);
 		return;
 	}
 
+	if (theme == NULL) {
+		theme = g_new0(struct smiley_theme, 1);
+		theme->path = g_strdup(file);
+		smiley_themes = g_slist_prepend(smiley_themes, theme);
+	}
+
 	dirname = g_path_get_dirname(file);
 
 	while (!feof(f)) {
@@ -341,14 +342,11 @@ void pidgin_themes_load_smiley_theme(con
 	if (!theme->name || !theme->desc || !theme->author) {
 		purple_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file);
 
+		smiley_themes = g_slist_remove(smiley_themes, theme);
 		pidgin_themes_destroy_smiley_theme(theme);
 		return;
 	}
 
-	if (new_theme) {
-		smiley_themes = g_slist_prepend(smiley_themes, theme);
-	}
-
 	if (load) {
 		GList *cnv;
 


More information about the Commits mailing list