changeset 28136:c91832e94473

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.
author Paul Aurich <paul@darkrain42.org>
date Sun, 02 Aug 2009 04:33:26 +0000
parents 0a056130718e
children da33da2e1a1e
files pidgin/gtkthemes.c
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkthemes.c	Sun Aug 02 04:10:32 2009 +0000
+++ b/pidgin/gtkthemes.c	Sun Aug 02 04:33:26 2009 +0000
@@ -229,7 +229,6 @@
 	struct smiley_list *list = NULL;
 	GSList *lst = smiley_themes;
 	char *dirname;
-	gboolean new_theme = FALSE;
 
 	if (!f)
 		return;
@@ -243,16 +242,18 @@
 		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 @@
 	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;