more memory leak fixes for the bonobo 1.0.x



The attached patch does not fix the "major" leak that is being reported
by purify, but I'm beginning to think purify might be on crack about
that leaked pixbuf, but anyways... as I was digging I found these few
possible leaks and thought I'd fix them in case they were related to
this monstrous leak purify was reporting. They weren't, but since I
fixed em I might as well send 'em in :-)

Ok to commit?

Jeff
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? bonobo-leak-fixes.patch
? bonobo-ui-sync-menu.c
? doc/api/bonobo-symbols.txt
? doc/api/bonobo-undocumented.txt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.1173
diff -u -r1.1173 ChangeLog
--- ChangeLog	3 Jun 2002 19:55:06 -0000	1.1173
+++ ChangeLog	7 Jun 2002 20:39:52 -0000
@@ -1,3 +1,15 @@
+2002-06-05  Jeffrey Stedfast  <fejj ximian com>
+
+	* bonobo/bonobo-ui-sync-toolbar.c
+	(impl_bonobo_ui_sync_toolbar_state): On error, make sure to free
+	any allocated string values. Also move getting the icon_pixbuf
+	into the if-statement so that if type != "toggle", we will not
+	leak the pixbuf and as an additional plus, won't have to waste
+	resources fetching it if we don't need it.
+
+	* bonobo/bonobo-ui-util.c (bonobo_ui_util_xml_get_icon_pixbuf): If
+	we fail to get an icon_pixbuf, don't forget to g_free() the key.
+
 2002-05-31  Jeffrey Stedfast  <fejj ximian com>
 
 	* bonobo/bonobo-ui-component.c (impl_xml_set):
Index: bonobo/bonobo-ui-sync-toolbar.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-sync-toolbar.c,v
retrieving revision 1.14
diff -u -r1.14 bonobo-ui-sync-toolbar.c
--- bonobo/bonobo-ui-sync-toolbar.c	15 Dec 2001 15:13:29 -0000	1.14
+++ bonobo/bonobo-ui-sync-toolbar.c	7 Jun 2002 20:39:53 -0000
@@ -128,13 +128,12 @@
 
 	bonobo_ui_toolbar_item_set_want_label (
 		BONOBO_UI_TOOLBAR_ITEM (widget), priority);
-
-	icon_pixbuf = cmd_get_toolbar_pixbuf (node, cmd_node);
-
+	
 	type  = bonobo_ui_engine_get_attr (node, cmd_node, "type");
 	label = bonobo_ui_engine_get_attr (node, cmd_node, "label");
 	
 	if (!type || !strcmp (type, "toggle")) {
+		icon_pixbuf = cmd_get_toolbar_pixbuf (node, cmd_node);
 		if (icon_pixbuf) {
 			bonobo_ui_toolbar_button_item_set_icon (
 				BONOBO_UI_TOOLBAR_BUTTON_ITEM (widget), icon_pixbuf);
@@ -143,11 +142,18 @@
 
 		if (label) {
 			gboolean err;
-			char *txt = bonobo_ui_util_decode_str (label, &err);
+			
+			txt = bonobo_ui_util_decode_str (label, &err);
+			
 			if (err) {
 				g_warning ("Encoding error in label on '%s', you probably forgot to "
 					   "put an '_' before label in your xml file",
-					   bonobo_ui_xml_make_path (node));
+					   (txt = bonobo_ui_xml_make_path (node)));
+				
+				bonobo_ui_node_free_string (type);
+				bonobo_ui_node_free_string (label);
+				g_free (txt);
+				
 				return;
 			}
 
Index: bonobo/bonobo-ui-util.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-util.c,v
retrieving revision 1.56
diff -u -r1.56 bonobo-ui-util.c
--- bonobo/bonobo-ui-util.c	15 May 2002 14:19:42 -0000	1.56
+++ bonobo/bonobo-ui-util.c	7 Jun 2002 20:39:54 -0000
@@ -480,7 +480,6 @@
 		/* Get pointer to GdkPixbuf */
 		icon_pixbuf = bonobo_ui_util_xml_to_pixbuf (text);
 
-		g_return_val_if_fail (icon_pixbuf != NULL, NULL);
 	} else
 		g_warning ("Unknown icon_pixbuf type '%s'", type);
 
@@ -490,6 +489,8 @@
 	if (icon_pixbuf) {
 		gdk_pixbuf_ref (icon_pixbuf);
 		g_hash_table_insert (pixbuf_cache, key, icon_pixbuf);
+	} else {
+		g_free (key);
 	}
 
 	return icon_pixbuf;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]