[Fxruby-users] Re: How to catch window destruction (was: Question...)
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <ly...@kn...> - 2004-02-27 15:31:49
|
On Feb 26, 2004, at 7:46 AM, Allen Mitchell wrote: > Another question.... > > I deceided to create a small class for button animation: <snip> > Works great, except that how do you catch the fact that the window is > destroying in order to cancel the time. In C++ I would have a > destructor, > but here I'm not sure. Generally speaking, I don't think there is a way to reliably catch the garbage collection of an object in Ruby. I've had at best mixed success using Ruby's finalizers for this kind of thing. However, in this case you may be able to override the widget's destroy() method and remove the timeout there: class FXAnimatedButton def destroy getApp().removeTimeout(...) super # call base class version of destroy() end end I have not tried this, but it seems like it should work. Hope this helps, Lyle |