GNOME Bugzilla – Bug 351072
Cannot handle signals with parameter type G_TYPE_VALUE (marshal/unmarshal for GValue-wrapped GValue)
Last modified: 2007-07-07 12:10:49 UTC
Background: at bug 345592 we want a polymorphic signal: one which has G_TYPE_VALUE as one of its parameter types. Currently pyg_value_{from,as}_pyobject does not handle the case where the GValue itself stores a GValue. It seems that fixing this would be the easiest way to enable such signals to be emitted and connected to from Python.
Confirming. Hint: if you don't need these signals to interface with C code, only from python to python, you can use the type 'object' to allow any python object as signal argument (in C land it is a boxed type).
Created attachment 71270 [details] [review] pygobject-marshal-gvalue-gvalue.patch Suggested patch.
Workaround is to use these functions in embedding code: static PyObject * pyg_value_g_value_as_pyobject (const GValue *value) { return pyg_value_as_pyobject((GValue *)g_value_get_boxed(value), FALSE); } static int pyg_value_g_value_from_pyobject (GValue *value, PyObject *obj) { GType type; GValue obj_value = { 0, }; type = pyg_type_from_object((PyObject *) obj->ob_type); if (! type) { PyErr_Clear(); return -1; } g_value_init(&obj_value, type); if (pyg_value_from_pyobject(&obj_value, obj) == -1) { g_value_unset(&obj_value); return -1; } g_value_set_boxed(value, &obj_value); g_value_unset(&obj_value); return 0; } ... init_pygobject (); pyg_register_gtype_custom (G_TYPE_VALUE, pyg_value_g_value_as_pyobject, pyg_value_g_value_from_pyobject);
(In reply to comment #2) > Created an attachment (id=71270) [edit] > pygobject-marshal-gvalue-gvalue.patch > > Suggested patch. > In general the patch looks good. But it's missing a test, do you think you can write a simple testcase demostrating this bug?
Created attachment 91313 [details] [review] TestCase
Created attachment 91314 [details] [review] Updated path to be commited in trunk
Created attachment 91315 [details] [review] Changelog
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.