[Kde-bindings] issue with disposed?

Stefano Crocco stefano.crocco at alice.it
Sat Aug 16 13:23:16 UTC 2008


I just found out that dispose? in qtruby4 doesn't seem to work as expected. 
From http://techbase.kde.org/Development/Languages/Ruby#Garbage_Collection, I 
understand that disposed? should return true after the object has been 
disposed of and (I think) false otherwise. Yet, in practice, its behavior is 
the opposite. The following code:

require 'Qt4'
o = Qt::Object.new
puts "o.disposed? before dispose: #{o.disposed?}"
o.dispose
puts "o.disposed? after dispose: #{o.disposed?}"

prints

o.disposed? before dispose: true
o.disposed? after dispose: false

which is the opposite of what I'd expect. The cause of the error (if it is 
indeed an error) comes from the definition of the is_disposed function in
kdebindings/ruby/qtruby/src/qtruby.cpp, which reads:

static VALUE
is_disposed(VALUE self)
{
  smokeruby_object *o = value_obj_info(self);
  if(o && o->ptr) { return Qtrue; }
  return Qfalse;
}

I think (also looking at the definition of dispose) that Qtrue and Qfalse 
should be switched.

Stefano



More information about the Kde-bindings mailing list