Fixing QtRuby with Ruby >= 1.8.4

We’d recently gotten some word from Debian users that QtRuby wasn’t playing nicely, and this was confirmed on Gentoo Linux yesterday. So I investigated:

It turns out that between 1.8.3 and 1.8.4, the rb_respond_to method was changed to not respond to private methods, and instead a rb_obj_respond_to was added that is more like the Object#respond_to? method, where there’s a true/false switch to include/exclude private methods from the search.

Here’s a key piece of QtRuby object initialization code:

    if (rb_respond_to(result, rb_intern("initialize")) != 0) {
        rb_obj_call_init(result, argc, argv);
    }

This works on Ruby 1.8.3, but fails on Ruby 1.8.4.

Richard and I decided just to forego the formalities of checking whether the object responds to initialize and call it anyway. I think worst case we’d just throw an exception, and the only way we’d do that is if we got a nil value back from the catch/throw initialization block.

I like how the C side of Ruby is being cleaned up, but this seems like a big jump for a minor release. Surely other existing extension code will fail in much the same way.

One Response to “Fixing QtRuby with Ruby >= 1.8.4”

  1. Daniel Berger Says:

    Since 1.8.2 there have been several internal changes like that, with no input from the Ruby community. Not the English speaking community, anyway. It’s highly irritating.

    I personally still consider 1.8.2 the last stable release.