[fxruby-users] test if a window has been destroyed

Joel VanderWerf vjoel at path.berkeley.edu
Thu Apr 19 12:15:02 EDT 2007

Lyle Johnson wrote:
> On 4/19/07, Joel VanderWerf <vjoel at path.berkeley.edu> wrote:
>> Is there a way to test if a FXWindow has been destroyed?
> If a window has been destroyed, or hasn't been created *yet*, then
> created? method should answer false:
>     window.create unless window.created?
>     window.show

A window that has been destroyed causes created? to fail with "This FXId 
* already released".

To see this, change glviewer.rb as follows:

--- glviewer.rb.bck     2007-04-19 09:13:28.000000000 -0700
+++ glviewer.rb 2007-04-19 09:13:28.000000000 -0700
@@ -272,6 +272,10 @@
      FXMenuCommand.new(filemenu, "&Dump...\t\tDump widgets.", nil, 
getApp(), FXApp::ID_DUMP)
      FXMenuCommand.new(filemenu, "&Quit\tCtl-Q\tQuit the application.", 
nil, getApp(), FXApp::ID_QUIT)

+    FXMenuCommand.new(filemenu, "Foobar", nil).connect(SEL_COMMAND) do
+      p mdichild.created?
+    end
      # Edit Menu
      editmenu = FXMenuPane.new(self)
      FXMenuTitle.new(menubar, "&Edit", nil, editmenu)

Then, run it, select the File/Foobar menu cmd, close the child window, 
and then select the File/Foobar menu cmd again. You shout get this:

$ ruby glviewer.rb
glviewer.rb:276:in `created?': This FXId * already released (RuntimeError)
         from glviewer.rb:276:in `initialize'
         from glviewer.rb:579:in `run'
         from glviewer.rb:579

       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

More information about the fxruby-users mailing list