[Vala] Type.from_name is returning null pointer



hi,

i am quite new to vala and the gobject type system. 
i like both very much. 

for an experimental project i'd like to create objects when only their
class name is given as a string (retrieving that string from a
database). so i'd like to use Type.from_name & Object.new for this. 

however, if i run the following sample code ...

public class MyObject:Object{}

void main () {          
 Type typeFromName = Type.from_name("MyObject"); 
 print("%s\n", typeFromName.to_string());       
 print("%s\n", typeFromName.name()); 
}

... i get the following output:

0
(null)

... which i obviously cannot use to create any object. 

i discovered that the code above works, but only if an object of
MyObject was previously created or if i previously used typeof(MyObject)
and assigned that type-object to some variable. 

maybe someone could help me here.
thank you very much in advance.

peter




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