summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-08-17 15:50:05 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-08-17 15:50:05 +0000
commitecf9af17b1d6e93a883f18bd6366eb68897559ae (patch)
tree06d6794001879d3cd13eb3d04798fc2c63338470
parent18bab9e20f4758394bc92b6e218c001f6a8665b5 (diff)
downloadpygobject-ecf9af17b1d6e93a883f18bd6366eb68897559ae.tar.gz
pygobject-ecf9af17b1d6e93a883f18bd6366eb68897559ae.tar.xz
pygobject-ecf9af17b1d6e93a883f18bd6366eb68897559ae.zip
fix interface registration
-rw-r--r--ChangeLog7
-rw-r--r--gobject/gobjectmodule.c62
2 files changed, 38 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index ce85e85..402de51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-17 Gustavo J. A. M. Carneiro <gjc@gnome.org>
+
+ * gobject/gobjectmodule.c (pyg_type_register): Move the interface
+ registration code up, to run before properties and signals
+ registration, because glib doesn't allow us to add interfaces
+ after the first call to g_class_ref.
+
2006-08-16 John Finlay <finlay@moeraki.com>
* docs/reference/pygobject-functions.xml: Update docs for
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 0004f43..8374c44 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -1274,6 +1274,37 @@ pyg_type_register(PyTypeObject *class, const char *type_name)
pyg_object_descr_doc_get());
}
+ /* Register interface implementations */
+ if (class->tp_bases) {
+ for (i = 0; i < PyTuple_GET_SIZE(class->tp_bases); ++i)
+ {
+ PyTypeObject *base =
+ (PyTypeObject *) PyTuple_GET_ITEM(class->tp_bases, i);
+ GType itype;
+ const GInterfaceInfo *iinfo;
+ GInterfaceInfo iinfo_copy;
+
+ if (((PyTypeObject *) base)->tp_base != &PyGInterface_Type)
+ continue;
+
+ itype = pyg_type_from_object((PyObject *) base);
+ iinfo = pyg_lookup_interface_info(itype);
+ iinfo_copy = *iinfo;
+ iinfo_copy.interface_data = class;
+ if (!iinfo) {
+ char *msg;
+ msg = g_strdup_printf("Interface type %s "
+ "has no python implementation support",
+ base->tp_name);
+ PyErr_Warn(PyExc_RuntimeWarning, msg);
+ g_free(msg);
+ continue;
+ }
+ g_type_add_interface_static(instance_type, itype, &iinfo_copy);
+ }
+ } else
+ g_warning("type has no tp_bases");
+
/* we look this up in the instance dictionary, so we don't
* accidentally get a parent type's __gsignals__ attribute. */
gsignals = PyDict_GetItemString(class->tp_dict, "__gsignals__");
@@ -1312,37 +1343,6 @@ pyg_type_register(PyTypeObject *class, const char *type_name)
PyErr_Clear();
}
- /* Register interface implementations */
- if (class->tp_bases) {
- for (i = 0; i < PyTuple_GET_SIZE(class->tp_bases); ++i)
- {
- PyTypeObject *base =
- (PyTypeObject *) PyTuple_GET_ITEM(class->tp_bases, i);
- GType itype;
- const GInterfaceInfo *iinfo;
- GInterfaceInfo iinfo_copy;
-
- if (((PyTypeObject *) base)->tp_base != &PyGInterface_Type)
- continue;
-
- itype = pyg_type_from_object((PyObject *) base);
- iinfo = pyg_lookup_interface_info(itype);
- iinfo_copy = *iinfo;
- iinfo_copy.interface_data = class;
- if (!iinfo) {
- char *msg;
- msg = g_strdup_printf("Interface type %s "
- "has no python implementation support",
- base->tp_name);
- PyErr_Warn(PyExc_RuntimeWarning, msg);
- g_free(msg);
- continue;
- }
- g_type_add_interface_static(instance_type, itype, &iinfo_copy);
- }
- } else
- g_warning("type has no tp_bases");
-
gclass = g_type_class_ref(instance_type);
if (pyg_run_class_init(instance_type, gclass, class)) {
g_type_class_unref(gclass);