[Gtk-sharp-list] IDisposable

Mike Kestner mkestner@speakeasy.net
04 Sep 2002 00:50:22 -0500


Since Miggy's been nagging me for it, I hacked in IDisposable support
for GLib.Objects tonight.  

All GLib.Objects now have destructors which will cause the native object
to be unref'd when the GC gets a hold of your objects.  So, expect some
interesting behavior if you've been lazy about retaining refs to your
objects.

Gtk.Objects override the default Dispose method and only unref if the
Object is still floating.  This should ensure that GtkWidgets which are
sinked by containers won't get unref'd accidentally.

If anyone detects major brokeness with the resulting behavior, don't be
bashful. 

There's still a small piece of work to be done to allow us to mark
objects returned by specific methods as "unowned" by the caller.  My
thought was to add a property to expose the disposed field which
currently guards against multiple Dispose calls.  Then we can just set
NeedsDisposal=false for any method return values we need to mark as
unowned-by-caller.

-- 
Mike Kestner <mkestner@speakeasy.net>