On Sat, 2009-01-10 at 23:48 +0100, Hans Vercammen wrote:
> Why do this manually? Don't you need to chain the dispose handlers
> throughout the hierarchy to make it usable somehow?
> As far as I understand the GObject dispose mechanism, it doesn't prevent
> the cyclic references from not being cleaned up. But it allows you to
> manually break them if they exist.
> Perhaps it would be a good idea to dispose the member references in the
> GObject dispose handler by default instead of the finalize handler. In
> this case the user could build a custom object management system on top
> of vala and call the dispose handler explicitly when required. Of course
> this could cause various side-effects when not used carefully. On the
> other hand so do raw pointers and preventing these memory leaks is as
> far as know only possible by using weak references.

The issue is that freeing everything already in dispose is not always
correct, it could lead to crashes if referenced objects access other
objects while being disposed.

However, dispose is available as a virtual method in Vala and overriding
it should provide you with the means necessary to support the GObject
dispose mechanism. When you make sure that there are no cycles by using
weak references, this is not necessary.

Jürg

_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to