From b5cf45145e8f0f62511aa072c0768612426455f1 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 9 Jan 2009 19:13:38 +0000 Subject: Add a comment explaining why the two for loops for registering interfaces. * gobject/gobjectmodule.c (pyg_type_register): Add a comment explaining why the two for loops for registering interfaces. svn path=/trunk/; revision=995 --- gobject/gobjectmodule.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'gobject') diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index aa7ee49..4180fbe 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1139,6 +1139,35 @@ pyg_type_register(PyTypeObject *class, const char *type_name) pyg_object_descr_doc_get()); } + /* + * Note: Interfaces to be implemented are searched twice. First + * we register interfaces that are already implemented by a parent + * type. The second time, the remaining interfaces are + * registered, i.e. the ones that are not implemented by a parent + * type. In between these two loops, properties and signals are + * registered. It has to be done this way, in two steps, + * otherwise glib will complain. If registering all interfaces + * always before properties, you get an error like: + * + * ../gobject:121: Warning: Object class + * test_interface+MyObject doesn't implement property + * 'some-property' from interface 'TestInterface' + * + * If, on the other hand, you register interfaces after + * registering the properties, you get something like: + * + * ../gobject:121: Warning: cannot add interface type + * `TestInterface' to type `test_interface+MyUnknown', since + * type `test_interface+MyUnknown' already conforms to + * interface + * + * This looks like a GLib quirk, but no bug has been filed + * upstream. However we have a unit test for this particular + * problem, which can be found in test_interfaces.py, class + * TestInterfaceImpl. + */ + + /* Register interfaces that are already defined by the parent * type and are going to be reimplemented */ if (class->tp_bases) { -- cgit