From 9efdc381329d8e656fe0b3a49f76af9647b18bbb Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Tue, 21 Jun 2005 16:12:05 +0000 Subject: Try to register unknown enums and flags on the fly. Fixes #308536, patch 2005-06-21 Johan Dahlin * gobject/pygparamspec.c: (pygenum_from_pspec), (pygflags_from_pspec): Try to register unknown enums and flags on the fly. Fixes #308536, patch by Edward Hervey * gobject/pygflags.c: (pyg_flags_add): Make module optional. --- gobject/pygflags.c | 1 - gobject/pygparamspec.c | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'gobject') diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 2f12324..51dd59a 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -194,7 +194,6 @@ pyg_flags_add (PyObject * module, GFlagsClass *eclass; int i; - g_return_val_if_fail(module != NULL, NULL); g_return_val_if_fail(typename != NULL, NULL); g_return_val_if_fail(g_type_is_a(gtype, G_TYPE_FLAGS), NULL); diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c index 28f9f47..13a526c 100644 --- a/gobject/pygparamspec.c +++ b/gobject/pygparamspec.c @@ -71,7 +71,9 @@ pygenum_from_pspec(GParamSpec *pspec) enum_type = G_ENUM_CLASS_TYPE(enum_pspec->enum_class); pyclass = (PyObject*)g_type_get_qdata(enum_type, pygenum_class_key); if (pyclass == NULL) { - pyclass = Py_None; + pyclass = pyg_enum_add(NULL, g_type_name(enum_type), NULL, enum_type); + if (pyclass == NULL) + pyclass = Py_None; } Py_INCREF(pyclass); @@ -89,7 +91,9 @@ pygflags_from_pspec(GParamSpec *pspec) flag_type = G_FLAGS_CLASS_TYPE(flag_pspec->flags_class); pyclass = (PyObject*)g_type_get_qdata(flag_type, pygflags_class_key); if (pyclass == NULL) { - pyclass = Py_None; + pyclass = pyg_flags_add(NULL, g_type_name(flag_type), NULL, flag_type); + if (pyclass == NULL) + pyclass = Py_None; } Py_INCREF(pyclass); return pyclass; -- cgit