diff options
Diffstat (limited to 'gobject')
| -rw-r--r-- | gobject/pygenum.c | 2 | ||||
| -rw-r--r-- | gobject/pygflags.c | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 24284d0..f7a6719 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -133,6 +133,8 @@ pyg_enum_from_gtype (GType gtype, int value) pyclass = (PyObject*)g_type_get_qdata(gtype, pygenum_class_key); if (pyclass == NULL) { pyclass = pyg_enum_add(NULL, g_type_name(gtype), NULL, gtype); + if (!pyclass) + return PyInt_FromLong(value); } values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict, diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 4a8211d..ca6eec0 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -156,9 +156,13 @@ pyg_flags_from_gtype (GType gtype, int value) g_return_val_if_fail(gtype != G_TYPE_INVALID, NULL); pyclass = (PyObject*)g_type_get_qdata(gtype, pygflags_class_key); - if (pyclass == NULL) - return PyInt_FromLong(value); + if (pyclass == NULL) { + pyclass = pyg_flags_add(NULL, g_type_name(gtype), NULL, gtype); + if (!pyclass) + return PyInt_FromLong(value); + } + values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict, "__flags_values__"); retval = PyDict_GetItem(values, PyInt_FromLong(value)); |
