Re: [gnome-db] GObject question



Le ven 21/06/2002 à 16:57, Rodrigo Moya a écrit :
> On Fri, 2002-06-21 at 15:23, Malerba_Vivien stna dgac fr wrote:
> > Hi!
> > 
> > I've got a question about the GObject's finalization methods.
> > I've realized to day that something is wrong with my code because I want
> > an object which is being free'd to be able to send signals. Here is what
> > happens:
> > - I call g_object_unref (object)
> > - the _finalize(object) methods gets called on the object and from this
> > method I want to send signals., so I call g_signal_emit()
> > - g_object_ref (object) is called by the GObject(s implementation but an
> > error appears:
> > 
> > GLib-GObject-CRITICAL **: file gobject.c: line 1292 (g_object_ref):
> > assertion `object->ref_count > 0' failed
> > 
> > Any idea how I could do the same without this error?
> > Do I have to override the "dispose" method and send signals from within
> > it?
> > 
> yes, AFAIK, the 'finalize' method is just for freeing memory. That is,
> you can't be sure the object will be in a status where you can send
> signals and stuff like that. It is just called when the object is being
> destroyed, not before it is destroyed.

All right, then I'll only do some memory freeing in this method.

> 
> I'm not sure there is another signal you could use to be notified before
> the object is destroyed.

I've made some tests and it looks like within the "dispose" method, the
ref_counter is still 1, so I assume the "dispose" method gets called
before the "finalize" method when an object is being free'd (this is
what I can see from the gobject.c file l.423). 

So I assume I can emit signals from within the "dispose" method, and the
I have quite a lot of modifications to be done on some objects.

Is there any way to make sure about that way of doing things?

Thanks,

Vivien




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