From e3135078a867a0dcd44647a480d990210e7496c2 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Wed, 4 Aug 2004 12:04:01 +0000 Subject: GdkModifierType is flags not an enum. * gtk/gtk.override (_wrap_gtk_accel_map_lookup_entry): GdkModifierType is flags not an enum. * gobject/pygenum.c (pyg_enum_from_gtype): Don't crash if its not an enum * gobject/pygflags.c (pyg_flags_from_gtype): Don't crash if its not flags --- gobject/pygenum.c | 2 ++ gobject/pygflags.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'gobject') 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)); -- cgit