diff options
| author | Lorenzo Gil Sanchez <lgs@src.gnome.org> | 2005-03-14 18:49:09 +0000 |
|---|---|---|
| committer | Lorenzo Gil Sanchez <lgs@src.gnome.org> | 2005-03-14 18:49:09 +0000 |
| commit | 063c04b0851097bf2a96f097a27e5b1a3825267a (patch) | |
| tree | 8f18f6b5d4dc2d202dfc0dc97f4357a890dda7b5 | |
| parent | 261cbc28a6fb29d745b99102a8ae0a061d3026bf (diff) | |
| download | pygtk-063c04b0851097bf2a96f097a27e5b1a3825267a.tar.gz | |
in case the enum is not registered, set enum_class or flag_class to None
* gobject/pygparamspec.c (pyg_param_spec_getattr): in case the enum
is not registered, set enum_class or flag_class to None
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | gobject/pygparamspec.c | 25 |
2 files changed, 23 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2005-03-14 Lorenzo Gil Sanchez <lgs@sicem.biz> + + * gobject/pygparamspec.c (pyg_param_spec_getattr): in case the enum + is not registered, set enum_class or flag_class to None + 2005-02-23 Cedric Gustin <cedric.gustin@swing.be> * gobject/pygtype.c (add_property_docs): Use G_CONST_RETURN with a diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c index fa4f5589..5dc52c4e 100644 --- a/gobject/pygparamspec.c +++ b/gobject/pygparamspec.c @@ -149,23 +149,34 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) if (G_IS_PARAM_SPEC_ENUM(self->pspec)) { GQuark quark; PyObject *pyclass; - + GParamSpecEnum *pspec; + GType enum_type; + quark = g_quark_from_static_string("PyGEnum::class"); - pyclass = (PyObject*)g_type_get_qdata(G_ENUM_CLASS_TYPE(G_PARAM_SPEC_ENUM(self->pspec)->enum_class), quark); - g_assert(pyclass != NULL); - + pspec = G_PARAM_SPEC_ENUM(self->pspec); + enum_type = G_ENUM_CLASS_TYPE(pspec->enum_class); + pyclass = (PyObject*)g_type_get_qdata(enum_type, quark); + if (pyclass == NULL) { + pyclass = Py_None; + } Py_INCREF(pyclass); return pyclass; + } } else if (!strcmp(attr, "flags_class")) { if (G_IS_PARAM_SPEC_FLAGS(self->pspec)) { GQuark quark; PyObject *pyclass; + GParamSpecFlags *pspec; + GType flag_type; quark = g_quark_from_static_string("PyGFlags::class"); - pyclass = (PyObject*)g_type_get_qdata(G_FLAGS_CLASS_TYPE(G_PARAM_SPEC_FLAGS(self->pspec)->flags_class), quark); - g_assert(pyclass != NULL); - + pspec = G_PARAM_SPEC_FLAGS(self->pspec); + flag_type = G_FLAGS_CLASS_TYPE(pspec->flags_class); + pyclass = (PyObject*)g_type_get_qdata(flag_type, quark); + if (pyclass == NULL) { + pyclass = Py_None; + } Py_INCREF(pyclass); return pyclass; } |
