After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620567 - "Default not in choices" error with correct XML schemas
"Default not in choices" error with correct XML schemas
Status: RESOLVED DUPLICATE of bug 616102
Product: glib
Classification: Platform
Component: gsettings
2.25.x
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-06-04 13:09 UTC by Milan Bouchet-Valat
Modified: 2010-06-04 18:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix compiling schemas with <choices> (1.90 KB, patch)
2010-06-04 13:52 UTC, Milan Bouchet-Valat
none Details | Review
Fix compiling schemas with <choices> (1.90 KB, patch)
2010-06-04 13:57 UTC, Milan Bouchet-Valat
none Details | Review

Description Milan Bouchet-Valat 2010-06-04 13:09:55 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>
Comment 1 Milan Bouchet-Valat 2010-06-04 13:52:15 UTC
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.
Comment 2 Milan Bouchet-Valat 2010-06-04 13:57:41 UTC
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.
Comment 3 Milan Bouchet-Valat 2010-06-04 13:58:49 UTC
Hum, a missing semicolon after while() did not resist real-world testing, so new patch.
Comment 4 Christian Persch 2010-06-04 18:08:37 UTC
This is fixed by the patches in bug 616102.

*** This bug has been marked as a duplicate of bug 616102 ***