[fxruby-users] Weird FXTable gc related problem

Jamey Cribbs cribbsj at oakwood.org
Mon May 16 11:24:52 EDT 2005

Ok, I've got a really weird problem cropping up.

I have a FXRuby app that is showing a FXTable with each row being a 
database record.  I have a menu on the screen.  If you select "Add" from 
the menu, my app opens up another window (FXDialog) that allows you to 
add a new record to the database.  If you click "Cancel" on this edit 
screen, it closes the FXDialog and takes you back to the FXTable screen 
and refreshes the data in the FXTable from the database.  This works fine.

I wanted to set up hotkeys to allow the user to do the exact same thing 
via keystrokes.  So I added an accelator to the acceltable for the app.  
When I test this, it bombs.  If I am sitting on the FXTable screen and I 
hit Ctrl+A, it opens the edit screen just like it should.  However, if I 
click on the "Cancel" button on this screen, my app bombs.  The error 
and line number it gives me hops around a little bit, but it goes 
something like this:

c:/work/ruby/lib/fxstuff/fxlistview.rb:188: [BUG] rb_gc_mark(): unknown 
data type 0x13(0x27341a4) non object
ruby 1.8.2 (2004-12-25) [i386-mswin32]

It is bombing in fxlistview.rb, which is my subclassed FXTable.

Something else interesting.  If I turn off garbage collection, this 
error does not occur.

Now, the strange thing is, I am executing the exact same routine when I 
click on the "Add" menu or when I hit "Ctrl+A".
Here is the code that  maps my  Add method to an ID:

       FXMAPFUNC(SEL_COMMAND,            ID_ADD,         :onCmdAdd)

Here is the code that adds the accelerator:

       self.accelTable.addAccel(fxparseAccel("Ctl-A"), self,

Here is the code that adds the menu command:

       @menuItems[:add] = FXMenuCommand.new(editmenu,
        "&Add\tCtl-A\tAdd a new record.", $icons[:add], self, ID_ADD)

It has something to do with garbage collection, but why would my app 
behave differently based on whether I click on a menu command or whether 
I press a hotkey.  Both are executing onCmdAdd using FXMAPFUNC.

Does any on this ring a bell to anyone?  I know it would help to post 
some code, but my app is pretty complex and it will take some work to 
rip out enough code to post something that would work.

Any hep would be greatly appreciated!

Jamey Cribbs

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

More information about the fxruby-users mailing list