Re: [evolution-patches] unref the gconf client,avoid mem leak!



JP & rodrigo!

sorry! I miss some places that should unref gconf client in the previous email. Please look the new patch.

Thanks
jack

jack wrote:

JP & rodrigo:
The patch is used for unref the gconf client, I found the similar patches commited to other module, I believe you should commit this patch.

Best Regards
jack


? calendar/gui/alarm-notify/.save.c.swp
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1792
diff -u -r1.1792 ChangeLog
--- calendar/ChangeLog	12 Jun 2003 11:16:33 -0000	1.1792
+++ calendar/ChangeLog	19 Jun 2003 03:40:12 -0000
@@ -1,3 +1,14 @@
+2003-06-10  Jack Jia <jack jia sun com>
+
+	* gui/alarm-notify/save.c (get_calendars_to_load): Unref the gconf client after we're finished.
+				  (save_calendars_to_load): ditto
+				  (save_blessed_program): ditto
+				  (is_blessed_program): ditto
+
+	* gui/itip-utils.c (itip_addresses_get): ditto
+	* pcs/cal-backend-util.c (cal_backend_mail_account_get_default): ditto
+                                 (cal_backend_mail_account_is_valid): ditto
+
 2003-06-10  Rodrigo Moya <rodrigo ximian com>
 
 	Fixes #41582
Index: calendar/gui/itip-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/itip-utils.c,v
retrieving revision 1.78
diff -u -r1.78 itip-utils.c
--- calendar/gui/itip-utils.c	30 May 2003 17:35:10 -0000	1.78
+++ calendar/gui/itip-utils.c	19 Jun 2003 03:40:14 -0000
@@ -70,8 +70,13 @@
 EAccountList *
 itip_addresses_get (void)
 {
+	GConfClient *gconf_client;
+	
+	gconf_client = gconf_client_get_default();
 	if (accounts == NULL)
-		accounts = e_account_list_new(gconf_client_get_default());
+		accounts = e_account_list_new(gconf_client);
+
+	g_object_unref (gconf_client);
 
 	return accounts;
 }
Index: calendar/gui/alarm-notify/save.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/save.c,v
retrieving revision 1.13
diff -u -r1.13 save.c
--- calendar/gui/alarm-notify/save.c	7 Mar 2003 12:53:19 -0000	1.13
+++ calendar/gui/alarm-notify/save.c	19 Jun 2003 03:40:14 -0000
@@ -110,6 +110,8 @@
 
 	gconf_client_set_list(gconf, KEY_CALENDARS, GCONF_VALUE_STRING, l, NULL);
 
+	g_object_unref (gconf);
+
 	g_slist_free(l);
 }
 
@@ -126,12 +128,14 @@
 {
 	GSList *l, *n;
 	GPtrArray *uris;
+	GConfClient *gconf_client;
 
 	/* Getting the default value below is not necessarily an error, as we
 	 * may not have saved the list of calendar yet.
 	 */
 
-	l = gconf_client_get_list (gconf_client_get_default (), KEY_CALENDARS, GCONF_VALUE_STRING, NULL);
+	gconf_client = gconf_client_get_default ();
+	l = gconf_client_get_list (gconf_client, KEY_CALENDARS, GCONF_VALUE_STRING, NULL);
 	uris = g_ptr_array_new ();
 	while (l) {
 		n = l->next;
@@ -140,6 +144,8 @@
 		l = n;
 	}
 
+	g_object_unref (gconf_client);
+
 	return uris;
 }
 
@@ -160,6 +166,7 @@
 	gconf_client_set_list(gconf, KEY_PROGRAMS, GCONF_VALUE_STRING, l, NULL);
 	g_slist_foreach(l, (GFunc)g_free, NULL);
 	g_slist_free(l);
+	g_object_unref (gconf);
 }
 
 /**
@@ -187,5 +194,6 @@
 		l = n;
 	}
 
+	g_object_unref (gconf);
 	return found;
 }
Index: calendar/pcs/cal-backend-util.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/cal-backend-util.c,v
retrieving revision 1.6
diff -u -r1.6 cal-backend-util.c
--- calendar/pcs/cal-backend-util.c	24 Feb 2003 02:59:24 -0000	1.6
+++ calendar/pcs/cal-backend-util.c	19 Jun 2003 03:40:15 -0000
@@ -62,9 +62,11 @@
 				      char **name)
 {
 	const EAccount *account;
+	GConfClient *gconf_client;
 
+	gconf_client = gconf_client_get_default ();
 	if (accounts == NULL)
-		accounts = e_account_list_new(gconf_client_get_default());
+		accounts = e_account_list_new(gconf_client);
 
 	account = e_account_list_get_default(accounts);
 	if (account) {
@@ -72,6 +74,8 @@
 		*name = g_strdup(account->id->name);
 	}
 
+	g_object_unref (gconf_client);
+
 	return account != NULL;
 }
 
@@ -79,13 +83,17 @@
 cal_backend_mail_account_is_valid (EConfigListener *db, char *user, char **name)
 {
 	const EAccount *account;
+	GConfClient *gconf_client;
 
+	gconf_client = gconf_client_get_default ();
 	if (accounts == NULL)
-		accounts = e_account_list_new(gconf_client_get_default());
+		accounts = e_account_list_new(gconf_client);
 
 	account = e_account_list_find(accounts, E_ACCOUNT_FIND_ID_ADDRESS, user);
 	if (account)
 		*name = g_strdup(account->id->name);
+
+	g_object_unref (gconf_client);
 
 	return account != NULL;
 }


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