GNOME Bugzilla – Bug 549061
Can't use GConf.Client.all_entries due to gconf_entry_ref not returning the pointer to an Entry
Last modified: 2009-01-16 16:04:57 UTC
I have the following code which I expected to compile fine: using GConf; int main () { GConf.Client gc = GConf.Client.get_default(); string root = "/apps/myapp"; weak GLib.SList<GConf.Entry> entrylist = gc.all_entries(root); foreach (GConf.Entry entry in entrylist) { stdout.printf("Key: %s Value: %s\n", entry.key, entry.get_value().get_bool()?"True":"False" ); } return 0; } But it fails with the following message: $ jhbuild run valac --pkg gconf-2.0 --pkg glib-2.0 vala-gconf-lists.vala vala-gconf-lists.vala:7.46-7.65: warning: unhandled error `GLib.Error' weak GLib.SList<GConf.Entry> entrylist = gc.all_entries(root); ^^^^^^^^^^^^^^^^^^^^ vala-gconf-lists.c: In function ‘_main’: vala-gconf-lists.c:40: error: void value not ignored as it ought to be error: cc exited with status 256 Compilation failed: 1 error(s), 1 warning(s) The corresponding line in the C Code is: entry = (_tmp1 = ((GConfEntry*) (entry_it->data)), (_tmp1 == NULL ? NULL : gconf_entry_ref (_tmp1))); The gconf_entry_ref (_tmp1) seems to be a problem. So if I do a foreach (weak GConf.Entry entry in entrylist) { it compiles fine.
Maybe this bug depends on bug 549063
With the patch from attachment #117245 [details] applied to GConf, I can build the first testcase.
Vala now supports [CCode (ref_function_void = true)], so this can be fixed in the bindings.
Created attachment 126161 [details] [review] Checks for void ref functions while running vapigen, patches the CodeWriter too untested
2009-01-16 Jürg Billeter <j@bitron.ch> * vala/valacodewriter.vala: Support void ref functions * vapigen/valagidlparser.vala: Detect void ref functions, patch by Andreas Brauchli, fixes bug 549061 * vapi/gconf-2.0.vapi: regenerated Fixed in r2354.