GNOME Bugzilla – Bug 54946
need a g_object_newv function
Last modified: 2011-02-18 15:47:37 UTC
It would be very useful to have a "g_object_newv" function in libgobject. The existing g_object_new and g_object_new_valist are inapropriate in cases where you can't use a C varargs function (eg. language bindings, or maybe a GUI builder). The contents of the g_object_new_valist is non trivial and accesses a few structure members that are marked private, so it doesn't seem safe for a user of the library to reimplement this function without the use of valists.
Created attachment 645 [details] [review] first go at g_object_newv patch
I just attached the first go at the g_object_newv patch. Haven't done much testing on it yet. I will attach another patch once it is tested a bit more and I have converted g_object_new_valist over to using g_object_newv (and documented it). Does the API look okay?
There should be a ! in the G_VALUE_HOLDS check I added in g_object_newv. The way it is now, it will fail on correctly typed values. Will fix in next version of patch.
Created attachment 649 [details] [review] revised g_object_newv patch
Attached revised version of patch, which fixes the logic error and converts g_object_new_valist to a wrapper around g_object_newv. The gtk-demo program seems to work fine with this patch applied, and so does the tests/simple test program (which makes use of this codepath). I believe this should be okay to apply (unless there are some issues with the API or bugs I haven't seen).
Tim applied patch to CVS, so marking bug as resolved.