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



tor, 21,.04.2005 kl. 16.23 +0800, skrev James Henstridge:
> 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.
> 
Fixed this one and a couple of others mentioned in this thread. Updated
patch is in bugzilla now:

http://bugzilla.gnome.org/show_bug.cgi?id=301945

> 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).
> 
Sounds like a good plan, but I didn't have time to rework all the uses
to follow this...

Cheers
Kjartan




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