Hi all.
I tried to subclass FXSettings in order to add some functionality to it
but I ran into the following problem.
The code which shall be executed looks like this:
def test
reg = Registry.new("test.reg")
reg.Parse
end
The Registry class basically looks this way:
require "fox12"
include Fox
class Registry < FXSettings
attr_accessor :mFile
attr_accessor :mDefaults
def initialize(aFile)
self.mFile = aFile
self.mDefaults = FXSettings.new
end
def Parse
parseFile(self.mFile, true)
Defaults(false)
end
def Write
unparseFile(self.mFile)
end
def Defaults(aOverwrite)
end
// Then a lot of stuff for setting default values and
// some model-view implementations follow but they aren''t of
// of importance regarding the error.
end
When I call reg.Parse now, the ruby interpreter prints out
./Registry.rb:26:in `parseFile'': This FXSettings * already released
(RuntimeError)
Does anyone see my - or FXRuby''s - mistake?
Regards,
Jannis
On Apr 12, 2005, at 4:56 PM, Jannis Pohlmann wrote:> When I call reg.Parse now, the ruby interpreter prints out > ./Registry.rb:26:in `parseFile'': This FXSettings * already > released (RuntimeError) > > Does anyone see my - or FXRuby''s - mistake?Yes; you need to call the base class initialize() method in your subclass'' initialize() method, e.g. class Registry < FXSettings def initialize(aFile) super() self.mFile = aFile self.mDefaults = FXSettings.new end end Hope this helps, Lyle
Lyle Johnson schrieb:> > On Apr 12, 2005, at 4:56 PM, Jannis Pohlmann wrote: > >> When I call reg.Parse now, the ruby interpreter prints out >> ./Registry.rb:26:in `parseFile'': This FXSettings * already >> released (RuntimeError) >> >> Does anyone see my - or FXRuby''s - mistake? > > > Yes; you need to call the base class initialize() method in your > subclass'' initialize() method, e.g. > > class Registry < FXSettings > def initialize(aFile) > super() > self.mFile = aFile > self.mDefaults = FXSettings.new > end > end > > Hope this helps, > > Lyle... Thanks very much, what a stupid mistake! Regards, Jannis (still banging his head against the table)