[fxruby-users] test if a window has been destroyed
vjoel at path.berkeley.edu
Thu Apr 19 15:37:54 EDT 2007
Lyle Johnson wrote:
> On 4/19/07, Meinrad Recheis <meinrad.recheis at gmail.com> wrote:
>> jeah, and interestingly a widget comes back to life when you call create
>> again. i found out that calling destroy on widgets does not remove them from
>> the widget tree and they come back to live after calling create on their
>> parent. but this is another story.
> Yes, this is as designed. Calling destroy() on a widget is (supposed
> to) only destroy the server-side resource and leave the client-side
> object (i.e. the Ruby instance) intact -- so that you could, as you
> noted, call create() on it to "re-realize" it. This is in contrast to,
> say, removeWidget(), which both destroys the server-side resource and
> deletes the client-side object.
> The message that Joel is seeing indicates that the underlying C++
> object has been destroyed (deleted) as well, which shouldn't happen if
> all you're doing is calling destroy on it. So I need to figure out
> what's going on there.
I *think* the following is a good workaround, and in some ways a better
approach than #destroyed? anyway (better to ask forgiveness than to ask
permission, as they say):
rescue => ex
if /already released/ =~ ex.message
window = make_window
I don't like matching the exception text though. I wonder if the
"already released" error could be represented by a subclass of RuntimeError?
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
More information about the fxruby-users