Re: GObject: Freeing memory of instance members?

2007-05-05 Thread Yeti
On Sat, May 05, 2007 at 05:45:06PM +0200, ??ystein Johansen wrote: > > Hello?! Wait a minute The macro (G_DEFINE_TYPE) prototypes the > instance init function to: > > static void my_thing_init( MyThing *self); > > (line 358 in my gtype.h) > > however API reference for GInstanceInitFunc() sa

Re: GObject: Freeing memory of instance members?

2007-05-05 Thread Øystein Johansen
Øystein Johansen wrote: > Wow! A really powerful macro. I actually had to run a 'gcc -E' to > convince myself. Here's what it does: > > Declare the functions: > _init > _class_init Hello?! Wait a minute The macro (G_DEFINE_TYPE) prototypes the instance init function to: static void my_thing_

Re: GObject: Freeing memory of instance members?

2007-05-05 Thread Øystein Johansen
David Nečas (Yeti) wrote: > Actually, what you should do is to use a macro from the > G_DEFINE_TYPE() family that does these things automaticaly > (the parent class variable is named _parent_class). Wow! A really powerful macro. I actually had to run a 'gcc -E' to convince myself. Here's what it d

Re: GObject: Freeing memory of instance members?

2007-05-05 Thread Yeti
On Thu, May 03, 2007 at 08:16:23PM -0300, Alexandre Moreira wrote: > > At your class_init you should peek (g_type_class_peek_parent, using > your class pointer as parameter) a pointer to your parent class and > keep it in a global storage, accessible to your finalize. Actually, what you should do

Re: GObject: Freeing memory of instance members?

2007-05-05 Thread Yeti
On Thu, May 03, 2007 at 08:03:15PM -0300, Alexandre Moreira wrote: > > Hey Yeti, since you're on the subject of object destruction, could you > explain me the difference between the finalize and dispose methods ? I > use finalize for everything but I believe I should be using dispose > somewhere,

Re: GObject: Freeing memory of instance members?

2007-05-03 Thread Alexandre Moreira
On 5/3/07, Øystein Johansen <[EMAIL PROTECTED]> wrote: > David Nečas (Yeti) wrote: > > On Thu, May 03, 2007 at 10:40:17PM +0200, ??ystein Johansen wrote: > >> Aha, but how/where to I set the pointer to the finalize() function? > > > > In my_class_init() where you override all other methods. > > See

Re: GObject: Freeing memory of instance members?

2007-05-03 Thread Alexandre Moreira
On 5/3/07, David Nečas (Yeti) <[EMAIL PROTECTED]> wrote: > On Thu, May 03, 2007 at 10:40:17PM +0200, ??ystein Johansen wrote: > > > > Aha, but how/where to I set the pointer to the finalize() function? > > In my_class_init() where you override all other methods. > See (almost) any Gtk+ widget for e

Re: GObject: Freeing memory of instance members?

2007-05-03 Thread Øystein Johansen
David Nečas (Yeti) wrote: > On Thu, May 03, 2007 at 10:40:17PM +0200, ??ystein Johansen wrote: >> Aha, but how/where to I set the pointer to the finalize() function? > > In my_class_init() where you override all other methods. > See (almost) any Gtk+ widget for examples. Aha again! I guess I can

Re: GObject: Freeing memory of instance members?

2007-05-03 Thread Yeti
On Thu, May 03, 2007 at 10:40:17PM +0200, ??ystein Johansen wrote: > > Aha, but how/where to I set the pointer to the finalize() function? In my_class_init() where you override all other methods. See (almost) any Gtk+ widget for examples. Yeti -- http://gwyddion.net/ ___

Re: GObject: Freeing memory of instance members?

2007-05-03 Thread Øystein Johansen
David Nečas (Yeti) wrote: > On Thu, May 03, 2007 at 09:51:05PM +0200, ?ystein Johansen wrote: >> I have an instance struct that has a pointer to a some data that's >> dynamically allocated in a method. How can I free this memory when the >> object is finalzed? Is this done automatically in g_object

Re: GObject: Freeing memory of instance members?

2007-05-03 Thread Yeti
On Thu, May 03, 2007 at 09:51:05PM +0200, ?ystein Johansen wrote: > > I have an instance struct that has a pointer to a some data that's > dynamically allocated in a method. How can I free this memory when the > object is finalzed? Is this done automatically in g_object_unref() (when > refcounter

GObject: Freeing memory of instance members?

2007-05-03 Thread Øystein Johansen
Hi, I've just started to use GObject, and I think I understand most of it by now. There's still some questions remaining. Here's one: I have an instance struct that has a pointer to a some data that's dynamically allocated in a method. How can I free this memory when the object is finalzed? Is th