[Kde-bindings] RubyQt: initializer Problem

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Nov 21 17:26:35 UTC 2005


Hi Hadmut

On Wednesday 16 November 2005 13:53, Hadmut Danisch wrote:
> Hi,
>
> I just ran into a problem with both a larger program and a smaller
> test program for rubyqt, which used to work some months ago, but now
> does not work anymore:
>
> It contains something like
>
> class CertEditorMain < Qt::MainWindow
>
>   def initialize()
> $stderr.puts "X1"
>     super
> $stderr.puts "X2"
>
>     filemenu = Qt::PopupMenu.new()
>     filemenu.insertItem("&Quit",$qApp,SLOT( "quit()" ) )
>     filemenu.insertItem("&Test", at certbox,SLOT("certify()"))
>
>     menubar = Qt::MenuBar.new( self, "" )
>     menubar.insertItem( "&File", filemenu )
>
>   end
>
> end
>
>
>
> begin
>   a = Qt::Application.new(ARGV)
>
> $stderr.puts "A1"
>   m = CertEditorMain.new
> $stderr.puts "A2"
>
> ...
>
>
>
> The problem is that it does not execute the code in the
> initialize-function after 'super' anymore, and thus things like
> filemenu, menubar etc. are not initialized. The inserted debugging
> messages proof this, it prints
>
> A1
> X1
> A2
>
> but not X2.
>
> The problem does not just occur with my own programs, but with the
> canvastest.rb example, that came with the rubyqt library. It used to
> work some time ago, but now just shows an empty window.
>
> I'm using debian linux,
> ruby 1.8.3 and libqt0-ruby1.8 4:3.4.2-2
>
>
> Debugging shows that when the main program calls initialize, it
> directly jumps into Internal.getSignalNames(klass) in qtruby.rb
>
> Then when calling super it jumps into
> Internal.do_method_missing, does some things and after that directly
> jumps back to the main program without finishing the initalize of the
> derived class.
This is a know problem with Debian, but I'm not sure what's causing it. There 
seems to be some strange problem about the way the Qt lib is built. It only 
seems to happen with Debian, and so I can't really debug it very easily. 
QtRuby actually runs the code before the super call in an intializer twice, 
throwing an exception and then going back in for the second time. It sounds 
like when it throws the execption it doesn't get caught, and so the second 
initialize() phase is missed.

-- Richard



More information about the Kde-bindings mailing list