Re: [Vala] problem with Object.get_class()



Hello,

I thought I've already answered this, but maybe I forgot.

              في ث، 08-03-2011 عند 15:49 +0300 ، كتب Maga Abdurakhmanov:
Any ideas? Is this a bug in Vala? Shouldn't x.get_class() return an instance
of ObjectClass ?

It should and it does in my tests :-)

The problem is that calling g_type_class_ref on the returned ObjectClass
returns null. I don't know exactly why, but I see the warning at C
compilation as a hint that there may be a bug in the bindings: why
g_type_class_ref is the ref function of GLib.TypeClass, when the former
is supposed to take a GType as a parameter.

Anyway, here is my answer, I found it in the drafts folder:

2011/3/3 Maga Abdurakhmanov <maqdev gmail com>:
It works when changed the line:

 ObjectClass objectClass = t1.get_class();

to:

ObjectClass objectClass = (ObjectClass)t;

I consider this to be a hack (and it may cause you trouble). I think you
should either use

unowned ObjectClass objectClass = t1.get_class();

if you have an object, or

ObjectClass objectClass = t.class_ref();

HTH,
Abderrahim




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]