Re: [Vala] Type.from_name is returning null pointer



hello.

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. 

This is, because types are registered only on the first use and not before. 
If you compile that code and look at the generated c-code, you see that the type is registered only when 
creating an instance.

- fabian



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