2013/8/28 Sebastian Götte <jaseg@...2974...>:
Be careful with placement new onto GObjects allocated by g_object_new. g_object_new puts some GObject type info into the first few bytes of the struct which is trashed when placement new invokes the whole constructor hierarchy beginning at GObject (the C++ class) since this class' constructor can not preserve the type info field's memory content. You will not notice that in normal operation except when using dynamic GObject type casts (those CLASS_NAME(object) macros) which will throw warnings on the console, though not crash, or when using g_object_unref, since the reference counter is initialized with 1 but overwritten to 0. Also, at many points in Inkscape's code base there are asserts that will crash Inkscape when they encounter a GObject lacking type information.
You should never call placement new on the GObject itself. But you have to call it on its members.