[Kde-bindings] Qt::Rect#inspect and Qt::RectF#inspect (qtruby4) conflict with yaml

Stefano Crocco stefano.crocco at alice.it
Mon Nov 24 11:41:21 UTC 2008


In qtruby4, Qt::Rect#inspect and Qt::RectF#inspect call the y method. However,
the yaml.rb file defines a Kernel#y method, which gets called instead of
self.y. Since the y method defined by yaml.rb requires an argument, while
Qt::Rect#y doesn't, this causes an error which is quite difficult to find
(I just spent at least an hour trying to locate it).

Here's how to reproduce the problem:

require 'Qt4'
require 'yaml'
r = Qt::Rect.new(1,2,3,4)
p r

And here's the corresponding error message

/usr/lib/ruby/site_ruby/1.8/Qt/qtruby4.rb:1468:in `y': wrong number of arguments (0 for 1) (ArgumentError)
	from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby4.rb:1468:in `inspect'
	from /home/stefano/documenti/scripts/prova.rb:4:in `p'
	from /home/stefano/documenti/scripts/prova.rb:4

The same happens with the pp method.

To solve the problem, it's enough to replace y with self.y in the definitions 
of Qt::Rect#inspect, Qt::Rect#pp, Qt::RectF#inspect and Qt::RectF#pp. I attach
a patch to qtruby4.rb which does exactly this (the patch needs to be applied
while in the ruby/qtruby/src/lib/Qt directory)

Stefano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rect_inspect.patch
Type: text/x-patch
Size: 1112 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20081124/2b227949/attachment.patch>


More information about the Kde-bindings mailing list