[MonoDevelop] What is the correct way of closing a Gtk dialog?

"Andrés G. Aragoneses" knocte at gmail.com
Fri May 23 05:11:53 EDT 2008


Chris Howie wrote:
> On Thu, May 22, 2008 at 11:28 AM, Michael Hutchinson
> <m.j.hutchinson at gmail.com> wrote:
>>> That is the correct way to close and dispose of all of the resources
>>> associated with a GObject, yes, and it works for GTK windows too.
>>> (Personally, I've always wondered why GObject doesn't implement
>>> IDisposable, but that's another discussion.)
>> Indeed. The confusing thing is that IDisposable IS implemented on GTK#
>> widgets but doesn't call Destroy -- and sadly, this can't be changed
>> without breaking backwards compatibility.
>>
>> However, this needn't be the case for new widgets. The first thing I
>> do when subclassing Dialog is to override Dispose with a version that
>> calls Destroy. Then I can use the 'using' pattern:
>> using (MyDialog dialog = new MyDialog ()) {
>>    somevalue = dialog.Run ();
>> }
> 
> And this, ladies and gentlemen, is why having preprocessor macros is a
> GOOD THING.
> 

I'd prefer a Gendarme rule.

Regards,

	Andres

-- 



More information about the Monodevelop-list mailing list