Version: (using KDE KDE 3.5.2) Installed from: Gentoo Packages sample script: -------------- require 'Qt' class A < Qt::Object def initialize p 'A' super p 'A end' end end A.new outputs: --------- "A" "A" "A end" Everything before the 'super' call is executed 2 times.
This is a known 'issue', due to the way QtRuby works. I believe the workaround is to make sure you call super first, but I'll let Richard chime in.
On Tuesday 16 May 2006 15:44, Caleb Tennis wrote: [bugs.kde.org quoted mail] I thought I already added a comment to this report. Here is the comment from the Qt.cpp code, that tries to explain the problem, and the reason why code before the super call is run twice: /* class LCDRange < Qt::Widget def initialize(s, parent, name) super(parent, name) init() ... For a case such as the above, the QWidget can't be instantiated until the initializer has been run up to the point where 'super(parent, name)' is called. Only then, can the number and type of arguments passed to the constructor be known. However, the rest of the intializer can't be run until 'self' is a proper T_DATA object with a wrapped C++ instance. The solution is to run the initialize code twice. First, only up to the 'super(parent, name)' call, where the QWidget would get instantiated in initialize_qt(). And then rb_throw() jumps out of the initializer returning the wrapped object as a result. The second time round 'self' will be the wrapped instance of type T_DATA, so initialize() can be allowed to proceed to the end. */ An ordinary Ruby instance is a T_OBJECT type in the C code, but once it wraps a C++ instance it is a T_DATA. So it is very difficult to work round it without the 'run twice' fix. -- Richard
Thank you for the bug report. As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists. If this bug is no longer persisting or relevant please change the status to resolved.
QtRuby only existed for Qt4 and Korundum, which never got updated for 5.x This is unmaintained and any effort towards QtRuby for Qt6 will be from scratch. Therefore, closing this ticket