[Kde-bindings] In qtruby, dispose causes irb to crash
Stefano Crocco
stefano.crocco at alice.it
Sat Mar 14 08:11:11 UTC 2009
The following code makes irb crash:
require 'Qt4'
o = Qt::Object.new
o.dispose
The reason, of course, is that dispose returns the disposed object and that
irb calls the inspect method of the value returned by each line. And since the
object has just been disposed, calling inspect on it causes a crash.
In my opinion, this is a problem because it's very confusing for the user: he
calls a method which should always succeed, and suddenly he gets a crash. The
first time it happened to me, I took a while to understand the reason of the
crash.
There could be several ways to solve this problem. The easiest would be to
make dispose return something other than the object, maybe nil. In my opinion,
this would also make more sense than returning an object most of whose methods
should not be called. Another option would be to change the inspect method to
check whether the object is disposed and, in that case, to return something
like "disposed".
Stefano
More information about the Kde-bindings
mailing list