summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2005-03-14 17:44:33 +0000
committerJohan Dahlin <johan@src.gnome.org>2005-03-14 17:44:33 +0000
commit8df9133eb9600278e5be6c9dc5906608c081e129 (patch)
tree920296d47f716632a9a1277ba91a17bea0366a06
parent77a9b4e3605fe3394eea52d4de34285bf213ac92 (diff)
downloadpygobject-8df9133eb9600278e5be6c9dc5906608c081e129.tar.gz
pygobject-8df9133eb9600278e5be6c9dc5906608c081e129.tar.xz
pygobject-8df9133eb9600278e5be6c9dc5906608c081e129.zip
In case the enum is not registered, set enum_class or flag_class to NonePYGTK_2_6_1
* 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.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c
index fa4f558..5dc52c4 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;
}