Re: [gnome-db]GdaConnectionPoolClass parent class



On 28 May 2001 21:18:42 +0200, Reinhard Mueller wrote:
> Ian D . Stewart wrote:
> 
> > Ok, as some of you know, I've been working on cleaning up the handling of
> > GObject v. GtkObject in libgda.  Right now I'm looking at
> > gda-connection-pool.h.  Specifically, I'm looking at the structure of
> > GdaConnectionPoolClass, and I've come across the following code:
> > 
> > #ifdef HAVE_GOBJECT
> > 	GObjectClass   parent_class;
> > 	GObjectClass   *parent;
> > #else
> > 	GtkObjectClass parent_class;
> > #endif
> > 
> > I'm assuming the duplication of parent and parent_class is an error.  If not,
> > and there is some reasoning behind this, please let me know.
> > 
> > For now, I intend to replace the above code with:
> > 
> > 	GdaObjectClass parent_class;
> 
> There was a reason for this.
> GObjectClass parent_class; is to incorporate all fields of the parent class.
> GObjectClass *parent; is a pointer to the instance of the class object 
> of the parent class. This is used so that the "inherited" finalize 
> method can be called from this class's finalize method.
> Other objects don't have this because they have no own finalize method.
> I am not 100% sure if this is the "right" method to do it. Members of 
> the gtk list proposed creating a global variable, which is a thing i 
> don't like (i don't like global variables at all).
> 
that's what I use myself (a global variable), or sometimes not even
that: in the place I need the parent_class:

ParentClass parent_class = gtk_type_class(gtk_object_get_type());

But well, since this seems to be very common, it would be a good idea to
add, to the GdaObject you're writing, that pointer, if it can be generic
at all.

> Whatever you do, please try to be clean with destroying/finalizing, as 
> memory holes will make libgda unusable for production systems.
> 
> 
yes, please, pay attention to this. I myself did a clean up of some objects some
time ago, but I'm sure there are still others not handling this very well, so,
please, if you find any gda_whatever_free function actually freeing the object's
struct members, just replace that code with a gtk/g_object_unref, and add a
destroy/finaliaze method for that class (or enter a new bug in http://bugzilla.gnome.org,
so that it's not forgotten.

cheers
--
Rodrigo Moya <rodrigo gnome-db org> <rodrigo ximian com>
http://www.gnome-db.org/





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