Support Gtk.Template on sub-classed Python classes
If Gtk.Template
is applied to a Python class which is a sub class of
another Python class then instance initialisation fails with the error
message: "gtk_widget_init_template: assertion 'template != NULL'
failed".
When initialising the GObject
instance which corresponds to Python
object that is being created, pygobject_g_instance_init()
is called once
for each Python class in the inheritance hierarchy of the Python object.
This method then calls __dontuse_ginstance_init__()
on the Python object
which in turn calls GtkWidget.init_template()
. However this method must
only be called once the GObject
instance is fully instantiated because
it is only then that the template member is initialised. This means
pygobject_g_instance_init()
should only call
__dontuse_ginstance_init__()
during its call to initialise the
most-derived class.
In order to achive this, this commit adds a check which compares the
current type id of the GObject
being initialised with the type id of the
final class of the object. Only if these to are equal
__dontuse_ginstance_init__()
is called.
This fixes #400.