Hello all.

I am writing my first Ruby program, which is a small GUI application,
based on the Fox library. The GUI is quite simple, consisting of one
list (FXList) which I want to add items, which again has two
properties, name and password, and a few buttons. The items are
implemented as a simple class Entry which extends FXListItem:

class Entry < FXListItem

  def initialize(name, password)
    @name = name
    @password = scramble(password)
  end
	
  def scramble(password)
    # This method will be more sofisticated in next iteration :-)
    password.reverse
  end
	
  def unscramble()
    @password.reverse
  end
	
  def to_s
    "Name: " + @name + ", Password: " + @password 
  end
end

When trying to add instances of this class to an FXList using the
appendItem method, I get into trouble. Here is the offending code:

    ...
    @list = FXList.new(self, 10, nil, 0, LIST_SINGLESELECT |
LAYOUT_FILL_X)
    item = Entry.new("xx", "yy")
    @list.appendItem(item)  # This line causes the error
    ...

and here is the error message I receive: 

c:/dev/ruby/lib/ruby/site_ruby/1.6/fox/overloads.rb:164:in
`appendItem1': This FXListItem * already released (RuntimeError)
        from c:/dev/ruby/lib/ruby/site_ruby/1.6/fox/overloads.rb:164:in
`appendItem'
        from PwdMgr.rb:71:in `initialize'
        from PwdMgr.rb:100:in `new'
        from PwdMgr.rb:100:in `run'
        from PwdMgr.rb:109


I also have tried to test the item variable using the
item.instance_of?(FXListItem) method, and it returns false, so I guess
I have got something wrong in my understanding of Ruby and
inheritance.

The C++ API doc says the following about appendItem: (Can't find a
Ruby version of the API doc. Does it exist?)

FXint appendItem(FXListItem* item, FXbool notify=FALSE) 
Append a [possibly subclassed] item to the list 

Can anyone tell me what I am doing wrong here?

Thanks!