-
Notifications
You must be signed in to change notification settings - Fork 63
FAQs
Consider this code:
class MyWidget < 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 initializer 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.