GNOME Bugzilla – Bug 620567
"Default not in choices" error with correct XML schemas
Last modified: 2010-06-04 18:08:37 UTC
It seems that it's not possible to compile a schema containing <choices> because default is always considered to be invalid. This can be checked by taking gio/tests/default-not-in-choices.gschema.xml and making it correct. It might be worth having tests for things that should succeed too. ;-) <schemalist> <schema id="test"> <key name="test" type="s"> <choices> <choice value="first" /> <choice value="last" /> </choices> <default>"first"</default> </key> </schema> </schemalist> $ ../glib-compile-schemas --dry-run --schema-file schema-tests/default-in-choices.gschema.xml schema-tests/default-in-choices.gschema.xml: Error on line 10 char 1: <default> contains string not in <choices>
Created attachment 162755 [details] [review] Fix compiling schemas with <choices> We must not free the choices at the end of the <choices> block, but at the end of the <key> block: found choices are used at that point to check whether <default> is actually in the list. Previously, is_valid_choices() was called after the list had been freed in end_element(), meaning default was always reported as wrong. Also fix is_valid_choices() to check for '\xff' as string separator instead of 0xff, which was causing an infinite loop.
Created attachment 162756 [details] [review] Fix compiling schemas with <choices> We must not free the choices at the end of the <choices> block, but at the end of the <key> block: found choices are used at that point to check whether <default> is actually in the list. Previously, is_valid_choices() was called after the list had been freed in end_element(), meaning default was always reported as wrong. Also fix is_valid_choices() to check for '\xff' as string separator instead of 0xff, which was causing an infinite loop.
Hum, a missing semicolon after while() did not resist real-world testing, so new patch.
This is fixed by the patches in bug 616102. *** This bug has been marked as a duplicate of bug 616102 ***