On 07/31/2013 05:51 PM, Krzysztof Kosiński wrote:
2013/7/30 Sebastian Götte <jaseg@...2974...>:
Hi, I'm currently having some problems allocating GObjects. I just added a class called SPPoint [0]. When I try to instantiate an object of that type (whether through SPObject/sp_object_child_added or manually from GDB using g_object_new does not matter), g_object_new returns an GObject* that contains a zero class: {g_type_instance = {g_class = 0x0}, ref_count = 0, qdata = 0x0} (this is not good as it breaks everything else about G_OBJECT). I was able to track down the problem to g_type_create_instance returning that when passed the new SPPoint type:
I think this is the problem:
static void sp_point_init(SPPoint *point){ new (point) SPPoint(); }
This will destroy parent initialization. Parent init functions which run before this one invoke the member constructors manually. In existing code, the constructor of SPObject is never called. The destructors are called manually in the dispose function. Instead of calling new, you have to construct each member separately.
Ah, I see. well, then it appears I can't use a C++ constructor here (I tried to avoid initializing all members to zero manually). Thanks.