Re: GObject Destruction

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

 



Il Tue, 18 Dec 2012 19:46:40 +0100 David Nečas <yeti@xxxxxxxxxxxxxxx> scrisse:

> On Tue, Dec 18, 2012 at 07:19:33PM +0100, Nicola Fontana wrote:
> > I always free dynamic stuff (included allocated memory) in
> > dispose(), not in finalize(), protecting it from double calls.
> > There you should have a still valid instance to query.
> 
> GObject gives the following, somewhat contradictory, requirements for
> dispose():
> 
>     When dispose ends, the object should not hold any reference to any
>     other member object. The object is also expected to be able to
>     answer client method invocations (with possibly an error code but no
>     memory violation) until finalize is executed. dispose can be
>     executed more than once.  dispose should chain up to its parent
>     implementation just before returning to the caller.
> 
> If you free everything in dipose() you may have troubles with the ‘able
> to answer client requests’ part.

That really depends on how you handle the data you are freeing.

I always wondered if this double step finalization is hystorical
craft. Why not drop finalize() altogether and avoid double dispose
calls directly from libgobject? You'd need to protect your code from
NULLs (something not new in C) but the finalization would be way
cleaner.

Ciao.
-- 
Nicola
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux