ryanmelt / qtbindings

An easy to install gem version of the Ruby bindings to Qt
http://github.com/ryanmelt/qtbindings
Other
340 stars 63 forks source link

fix #qt_methods on anonymous classes #92

Closed doudou closed 10 years ago

doudou commented 10 years ago

Anonymous classes have a name that's nil, and #qt_methods will bail out on them (because of find_pclassid). This breaks core Ruby methods as e.g. instance_methods, to reproduce:

Class.new.instance_methods
ryanmelt commented 10 years ago

I don't see anything wrong....

    loop do
      classid = Qt::Internal::find_pclassid(klass.name)
      break if classid.index

      klass = klass.superclass
      if klass.nil?
        return meths
      end
    end

If klass.name is nil then the returned classid won't have an index. It then moves onto the superclass which does have a name and all is good.

If you can provide a better example as to what you think is wrong, I will look into it some more.

Here is the output of Class.new.instance_methods for me:

qDebug
qFatal
qWarning
SIGNAL
SLOT
emit
QT_TR_NOOP
QT_TRANSLATE_NOOP
nil?
===
=~
!~
eql?
hash
<=>
class
singleton_class
clone
dup
initialize_dup
initialize_clone
taint
tainted?
untaint
untrust
untrusted?
trust
freeze
frozen?
to_s
inspect
methods
singleton_methods
protected_methods
private_methods
public_methods
instance_variables
instance_variable_get
instance_variable_set
instance_variable_defined?
instance_of?
kind_of?
is_a?
tap
send
public_send
respond_to?
respond_to_missing?
extend
display
method
public_method
define_singleton_method
object_id
to_enum
enum_for
==
equal?
!
!=
instance_eval
instance_exec
__send__
__id__

Also here the output of Class.new(Qt::Pixmap).instance_methods:

load
method_missing
const_missing
dispose
isDisposed
disposed?
qVariantValue
qVariantFromValue
**
+
~
-@
-
*
/
%
>>
<<
&
^
|
<
<=
>
>=
==
is_a?
kind_of?
methods
protected_methods
public_methods
singleton_methods
qDebug
qFatal
qWarning
SIGNAL
SLOT
emit
QT_TR_NOOP
QT_TRANSLATE_NOOP
nil?
===
=~
!~
eql?
hash
<=>
class
singleton_class
clone
dup
initialize_dup
initialize_clone
taint
tainted?
untaint
untrust
untrusted?
trust
freeze
frozen?
to_s
inspect
private_methods
instance_variables
instance_variable_get
instance_variable_set
instance_variable_defined?
instance_of?
tap
send
public_send
respond_to?
respond_to_missing?
extend
display
method
public_method
define_singleton_method
object_id
to_enum
enum_for
equal?
!
!=
instance_eval
instance_exec
__send__
__id__
colorCount
depth
devType
height
heightMM
logicalDpiX
logicalDpiY
numColors
paintEngine
paintingActive
physicalDpiX
physicalDpiY
width
widthMM
alphaChannel
cacheKey
convertFromImage
copy
createHeuristicMask
createMaskFromColor
detach
fill
alpha?
alphaChannel?
detached?
null?
qBitmap?
load
loadFromData
macCGHandle
macQDAlphaHandle
macQDHandle
mask
!
rect
save
scaled
scaledToHeight
scaledToWidth
scroll
serialNumber
alphaChannel=
mask=
size
swap
toImage
toMacCGImageRef
transformed
doudou commented 10 years ago

My mistake. I just realized that I was using the debian-provided package for qtruby, which is really really stale (last commit 5th of May 2012). This particular bug was fixed on qtbindings in 2012, and the fix is not included in the ruby package.

How is the relationship between qtbindings and the korundum project (is there one at all ?). Would be great to get all the work you've done in the distribution's packages.

ryanmelt commented 10 years ago

No relation between the projects except that I forked qtruby years ago and fixed most of the bugs. As far as I can tell, the qtruby part of kde bindings is dead. Arno Rehn and Richard Dale are no longer contributing. Anyone is free to merge my changes back into that codebase, but I would recommend just getting the distributions to use this code (though it does not contain any of the KDE specific things).