[Kde-bindings] name conflict between Qt::Widget#raise and Kernel#raise

Stefano Crocco stefano.crocco at alice.it
Sun May 24 12:35:52 UTC 2009


From inside a Qt::Widget, you can't raise an exception using raise, because 
it's shadowed by Qt::Widget#raise method. For example, take the following 
code:

class W < Qt::Widget
  
  def raise_error
    raise RuntimeError, "This is an exception"
  end
  
end

a = Qt::Application.new []
w = W.new
w.raise_error

What I'd expect, of course, is a RuntimeError raised by the last line of code. 
Instead, ruby attempts to call Qt::Widget#raise and gives a NoMethodError 
because Qt::Widget#raise takes no argument.

I can solve this problem by calling Kernel.raise instead of simply raise, but 
I think this is:
a) confusing for the user, who might even not be aware that raise is a method 
and think it a keyword
b) undesirable, because I think it's much more common to want to raise an 
exception than to use Widget#raise.

In my opinion, the best course of action would be to rename Qt::Widget#raise 
to Qt::Widget#raise_widget or Qt::Widget#raise_to_top or something similar, so 
that Kernel#raise can be freely accessed.

Stefano



More information about the Kde-bindings mailing list