[Kde-bindings] QtRuby virtual method callbacks

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Jul 17 08:39:02 UTC 2003


On Thursday 17 July 2003 01:10, Germain Garand wrote:
> Le Mardi 15 Juillet 2003 18:57, Richard Dale a écrit :
> > I've got QtRuby virtual method callbacks working, like paintEvent() in
> > the example below. But I've hit a snag with calling the C++ super method
> > from ruby, which is why 'super' has been commented out.
>
> By Heisenberg's ashes!
> Holidays are a great occasion to experience how things happen only when you
> don't observe them :-)
> Well done Richard!!
> The ruby code is amazingly clear when compared to its perl counterpart...
Yes, now I've finally got started I wish a had done it a bit earlier, oh well. 
I'm a real fan of ruby already - both the language and the C interface. The 
main thing still to be done are signals/slots, and I think I'll put it in the 
cvs when they're working. Yesterday I found the sources 'slots.pm, signals.pm 
and isa.pm' under lib/Qt - I hadn't realised they were there. I had just kept 
staring and staring at Qt.pm trying to see how it worked, but when I got to 
see 'isa.pm' the lightbulb finally switched on in my head :)

The problem with super calls not being forwarded to method_missing is 
apparently a bug which has been fixed in the latest version of ruby 1.8 - but 
I don't think that is too important anyway.

I've attached a current snapshot of qtruby. I'm working through the tutorials, 
and am up to t4.rb. To get that working I need to add a custom QApplication 
constructor to set up the Qt::app class variable, like PerlQt. There is a bug 
in the smoke munged name for the method - it's 'QApplication$?' when it 
should be 'QApplication?$' for 'int&, char**' in C++ - easy enough to work 
round. But every other language will only every have one argument instead of 
two, so I think it should really be 'QApplication$' and the 'char**' 
marshaller should take a single ruby or perl array, and push two args onto 
the smoke stack. And do the opposite going the other way from C++ to 
scripting language.

> Now, I must confess that I failed to run the actual examples, though the
> extension compiled flawlessly (following your directions).
> No matter how I compile it, it keeps segfaulting that way:
Oh dear it hasn't even got going! I usually have problems with pthreads (and 
dynamic_casts too) when l link against libs built with different versions of 
gcc - I wonder if the old qt lib is built with an older compiler?

-- Richard

> [Switching to Thread 16384 (LWP 12247)]
> 0x40ed0d55 in __pthread_unlock () from /lib/i686/libpthread.so.0
> (gdb) bt
> #0  0x40ed0d55 in __pthread_unlock () from /lib/i686/libpthread.so.0
> #1  0x40ecde85 in pthread_mutex_unlock () from /lib/i686/libpthread.so.0
> #2  0x401830e9 in _dl_open () from /lib/i686/libc.so.6
> #3  0x40024f21 in dlopen () from /lib/libdl.so.2
> #4  0x4000a828 in _dl_catch_error (objname=0x40026f60,
> errstring=0x40026f64, operate=0x40024ef0 <dlopen+80>, args=0xbfffd720) at
> dl-error.c:162 #5  0x40025294 in dlerror () from /lib/libdl.so.2
> #6  0x40024ed3 in dlopen () from /lib/libdl.so.2
> #7  0x080ba737 in dln_load ()
> #8  0x0805d0d6 in rb_f_require ()
> #9  0x0805a292 in rb_stack_check ()
> #10 0x0805a986 in rb_stack_check ()
> #11 0x0805b1f1 in rb_stack_check ()
> #12 0x08055de1 in rb_alias ()
> #13 0x080543de in rb_alias ()
> #14 0x08052696 in ruby_run ()
> #15 0x08050ac5 in main ()
> #16 0x4008b7f7 in __libc_start_main () from /lib/i686/libc.so.6
>
> That is with ruby 1.6.8, Qt-3.1.1 (stock Mandrake 9.1)/ Qt-3.1.2 (old
> qt-copy)
>
> I tried compiling with  -DQT_THREAD_SUPPORT  -D_REENTRANT
> to no avail :-/
>
> Germain
>
>
> _______________________________________________
> Kde-bindings mailing list
> Kde-bindings at mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-bindings
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qtruby_0.5.tar.gz
Type: application/x-tgz
Size: 33327 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20030717/616d7d2b/attachment.bin>


More information about the Kde-bindings mailing list