[Gtk-sharp-list] Feature Suggestion: implement IDispose
John Luke
jluke@users.sourceforge.net
Mon, 03 May 2004 21:22:58 -0400
On Mon, 2004-05-03 at 21:12 -0400, Jonathan Pryor wrote:
> This suggestion may be too late to actually be implemented any time
> soon, but it just occurred to me. Sorry.
>
> Would it make sense for the code generator to automagically insert the
> System.IDisposable interface on all GtkObject-derived objects,
> implementing System.IDisposable.Dispose to automatically invoke
> Gtk.Object.Destroy?
>
> This would allow the ultra-cool resource-handling code:
>
> using (Gtk.Dialog d = new Gtk.Dialog (...)) {
> /* Use `d'. Gtk.Object.Destroy automatically
> called at end of block. */
> }
>
> Which certainly beats manually calling Gtk.Object.Destroy (easy to
> forget), or (worse) try...finally blocks. It would also bring some
> consistency between the normal .NET libraries and Gtk#.
>
> The downside is that you're aiming for a 1.0 release Real Soon Now, so
> this is probably too much work at this time.
>
This is already done I believe, at least for all Dialogs it works, and
we use that throughout MonoDevelop. I don't believe it calls
Gtk.Object.Destroy though.