Re: Attempt to clean up gconf usage in gnomecc some...



Kjartan Maraas wrote:

>@@ -1107,15 +1113,20 @@ peditor_numeric_range_widget_changed (GC
> 				      GtkAdjustment       *adjustment)
> {
> 	GConfValue *value, *value_wid, *default_value;
>+	GConfClient *client;
> 
> 	if (!peditor->p->inited) return;
> 
> 	/* We try to get the default type from the schemas.  if not, we default
> 	 * to a float.
> 	 */
>+	client = gconf_client_get_default();
>+
> 	default_value = gconf_client_get_default_from_schema (gconf_client_get_default (),
> 							      peditor->p->key,
> 							      NULL);
>+	g_object_unref (client);
>+
> 	if (default_value)
> 		value_wid = gconf_value_new (default_value->type);
> 	else {
>  
>
This bit doesn't look like it leaves the reference leak -- instead of
calling gconf_client_get_default() once and g_object_unref() zero times,
it calls gconf_client_get_default() twice and g_object_unref() once.

In a lot of these cases, wouldn't it be easier to just get the
GConfClient once at application startup, store it in a global variable
and use that each time?  It looks like this patch adds a bit of clutter
for only theoretical gains -- since the default GConfClient is
essentially a singleton, the only thing you really need to worry about
is reference count wrap around (which is not likely to happen and could
be solved by just getting the client at startup).

James.



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