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 | d35ae11e9c98534e1761bd57b5c46fe9af89fe27 (patch) | |
tree | 55fa861cb0586a17e453d3b669ab30ebd0cbaef4 | |
parent | 35a8a21e95e630a66b3c10f8210a5d0c671648cc (diff) | |
download | pygobject-pygtk-2-4.tar.gz |
in case the enum is not registered, set enum_class or flag_class to Nonepygtk-2-4
* 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-- | gobject/pygparamspec.c | 25 |
1 files changed, 18 insertions, 7 deletions
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; } |