[Gtk-sharp-list] Feature Suggestion: implement IDispose

Jonathan Pryor jonpryor@vt.edu
Mon, 03 May 2004 21:12:17 -0400


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.

Thoughts?

 - Jon